ftp-upload-1.6/0002775000175000000620000000000013231420655013122 5ustar roderickstaffftp-upload-1.6/debian/0002775000175000000620000000000013231420566014345 5ustar roderickstaffftp-upload-1.6/debian/control0000664000175000000620000000107210406272132015741 0ustar roderickstaffSource: ftp-upload Section: net Priority: optional Maintainer: Roderick Schertler Standards-Version: 3.6.2 Build-Depends: debhelper (>= 3.0.5), perl (>= 5.6.0-16) Package: ftp-upload Architecture: all Depends: ${perl:Depends}, libnet-perl Description: put files with FTP from a script ftp-upload transfers local files to another machine using FTP. It's meant to be used by scripts and such rather than interactively. There's no user interface, the program is controlled strictly via the command line. It is disciplined with its exit status. ftp-upload-1.6/debian/rules0000775000175000000620000000260507331530453015427 0ustar roderickstaff#!/usr/bin/make -f # $Id: rules,v 1.4 2001/07/31 13:22:51 roderick Exp $ dt := debian/ftp-upload prefix = `pwd`/$(dt) stamp_build := debian/stamp.build stamp_install := debian/stamp.install clean := $(stamp_build) $(stamp_install) ifneq "" "$(findstring debug,$(DEB_BUILD_OPTIONS))" CFLAGS += -g endif export DH_COMPAT := 3 PERL ?= perl build: $(stamp_build) $(stamp_build): dh_testdir $(PERL) Makefile.PL INSTALLDIRS=vendor $(MAKE) OPTIMIZE="-O2 -Wall $(CFLAGS)" $(MAKE) test touch $@ install: $(stamp_install) $(stamp_install): $(stamp_build) dh_testdir dh_testroot dh_clean -k dh_installdirs $(MAKE) install PREFIX=$(prefix)/usr find $(prefix) -depth -type d -print0 | \ xargs -0r rmdir --ignore-fail-on-non-empty touch $@ clean: dh_testdir dh_testroot [ ! -f Makefile ] || $(MAKE) realclean dh_clean $(clean) binary: binary-indep binary-arch binary-arch: binary-indep: $(stamp_install) dh_testdir dh_testroot # dh_installdebconf dh_installdocs dh_installexamples dh_installmenu # dh_installlogrotate # dh_installemacsen # dh_installpam # dh_installmime # dh_installinit dh_installcron dh_installman dh_installinfo # dh_undocumented dh_installchangelogs dh_link dh_strip dh_compress dh_fixperms # dh_makeshlibs dh_installdeb dh_perl dh_shlibdeps dh_gencontrol -u -isp dh_md5sums dh_builddeb .PHONY: build install clean binary-indep binary-arch binary ftp-upload-1.6/debian/copyright0000664000175000000620000000150707263503557016313 0ustar roderickstaff$Id: copyright,v 1.2 2001/04/07 03:20:15 roderick Exp $ Copyright (C) 1999 Roderick Schertler. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. For a copy of the GNU General Public License write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA On Debian systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL'. ftp-upload-1.6/debian/watch0000664000175000000620000000017410406272230015370 0ustar roderickstaff# $Id: watch,v 1.2 2006-03-16 14:22:16 roderick Exp $ version=2 http://www.argon.org/~roderick/ftp-upload-(\d.*)\.tar\.gz ftp-upload-1.6/debian/changelog0000664000175000000620000000433413231420417016214 0ustar roderickstaffftp-upload (1.6) unstable; urgency=low * Add --no-passive to force active mode transfers. -- Roderick Schertler Mon, 22 Jan 2018 12:33:00 -0500 ftp-upload (1.5) unstable; urgency=low * Add --tmp-format. * Bump Standards-Version to 3.6.2 (no changes). -- Roderick Schertler Thu, 16 Mar 2006 09:18:34 -0500 ftp-upload (1.4) unstable; urgency=low * Oops, the -d alias for --dir didn't work (closes: #192134). * Add debian/watch. -- Roderick Schertler Tue, 6 May 2003 15:06:43 -0400 ftp-upload (1.3) unstable; urgency=low * Add --full-path. I'm afraid this is another incompatible change but I think the new behavior is much less surprising. If you upload /etc/motd it will now by default be stored as motd rather than /etc/motd. Use --full-path to get the old behavior back. * Correct --tmp-samedir and --tmp-dir handling when the local file name contains a directory. * Update to policy 3.5.6 (no changes). -- Roderick Schertler Thu, 29 Nov 2001 09:42:17 -0500 ftp-upload (1.2) unstable; urgency=low * Have --tmp-dir use a plain STOR rather than STOU. Technically this breaks backwards compatibility, but I suspect that it won't hurt anybody, and doing it this way makes a lot more sense. * Add --passive (closes: #115554). -- Roderick Schertler Mon, 15 Oct 2001 13:59:42 -0400 ftp-upload (1.1-1) unstable; urgency=low * Don't install extraneous empty directories (closes: #101344). -- Roderick Schertler Tue, 31 Jul 2001 09:15:19 -0400 ftp-upload (1.1) unstable; urgency=low * Update to policy 3.5.2 (closes: #91159, #91459). * Update to latest Perl policy. * Adjust for new Getopt::Long. -- Roderick Schertler Fri, 6 Apr 2001 23:12:41 -0400 ftp-upload (1.0) unstable; urgency=low * Adjust for new Perl packages. * Add --ignore-quit-failure switch. -- Roderick Schertler Tue, 6 Jul 1999 18:27:02 -0400 ftp-upload (0.1) unstable; urgency=low * Initial version. -- Roderick Schertler Sun, 7 Feb 1999 16:19:25 -0500 $Id: changelog,v 1.12 2018/01/22 17:36:15 roderick Exp $ ftp-upload-1.6/Makefile.PL0000664000175000000620000000052306657411177015107 0ustar roderickstaff# $Id: Makefile.PL,v 1.1 1999/02/07 22:23:59 roderick Exp $ use ExtUtils::MakeMaker; WriteMakefile( EXE_FILES => ['ftp-upload'], NAME => 'ftp-upload', PREREQ_PM => { 'Net::FTP' => 0 }, VERSION_FROM => 'ftp-upload', ); sub MY::dist_core { return q(dist:; @echo "use dpkg-buildpackge, not make dist" >&2; false); } ftp-upload-1.6/ftp-upload0000775000175000000620000003775013231420413015125 0ustar roderickstaff#!/usr/bin/perl -w use strict; # $Id: ftp-upload,v 1.13 2018/01/22 17:36:11 roderick Exp $ # # Roderick Schertler # Copyright (C) 1999 Roderick Schertler # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or (at # your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # For a copy of the GNU General Public License write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA use sigtrap qw(die normal-signals); # do END processing upon signals use File::Basename qw(basename dirname); use Getopt::Long (); use Net::FTP (); sub TMP_NONE () { 0 } sub TMP_SAMEDIR () { 1 } sub TMP_FORMAT () { 2 } my # new line required for makemaker $VERSION = '1.6'; my $Account = undef; my @As = (); my $Debug = 0; my @Dir = (); # array for multiple chdirs between files my $Exit = 0; my $Force_passive = undef; my $Full_path = 0; my $Ftp = undef; # Net::FTP object my $Host = undef; my $Ignore_quit_failure = 0; my $Ls = 0; my $Me = basename $0; my $Password = undef; my $Password_fd = undef; my $Tmp_format = undef; my $Tmp_strategy = TMP_NONE; my $Transfer_type = 'I'; my $User = undef; my $Verbose = 0; my @Option_once = ( 'account=s' => \$Account, 'debug!' => \$Debug, 'help' => sub { usage() }, 'host|h=s' => \$Host, 'ignore-quit-failure!' => \$Ignore_quit_failure, 'passive!' => \$Force_passive, 'password-fd=i' => \$Password_fd, 'password-stdin|s' => sub { $Password_fd = fileno STDIN }, 'password=s' => \$Password, 'user|u=s' => \$User, 'verbose|v' => \$Verbose, 'version' => sub { print "$Me version $VERSION\n"; exit }, ); my @Option_repeatable = ( 'as=s@' => \@As, 'ascii|a' => sub { $Transfer_type = 'A' }, 'binary|b' => sub { $Transfer_type = 'I' }, 'dir|d=s@' => \@Dir, 'full-path!' => \$Full_path, 'ls!' => \$Ls, # XXX work around bogus warning from Getopt::Long by using 2 specs 'l' => \$Ls, 'L' => sub { $Ls = 0 }, 'tmp-dir=s' => sub { $Tmp_strategy = TMP_FORMAT; ($Tmp_format = $_[1]) =~ s/%/%%/g; $Tmp_format .= "/%s"; }, 'tmp-format=s' => sub { $Tmp_strategy = TMP_FORMAT; $Tmp_format = $_[1]; }, 'tmp-none' => sub { $Tmp_strategy = TMP_NONE }, 'tmp-samedir' => sub { $Tmp_strategy = TMP_SAMEDIR }, ); my $Usage = <code; my $message = $Ftp->message; chomp $message; "$text ($code $message)\n"; } sub ftp_warn { xwarn ftp_warndie_mess @_; } sub ftp_die { xdie ftp_warndie_mess @_; } # Getopt::Long has some really awful defaults. This function loads it # then configures it to use more sane settings. sub configure_getopt { Getopt::Long->import(2.11); # I'm setting this environment variable lest he sneaks more bad # defaults into the module. local $ENV{POSIXLY_CORRECT} = 1; Getopt::Long::config qw( default no_autoabbrev no_getopt_compat require_order bundling no_ignorecase ); } # Getopt::Long 2.11 triggers a warning with the args I give it, so # disable warnings when calling it. sub getopt { local $^W; # Technically, this works because I'm in the same package as my # caller or because I'm not using globals to store the options. # Using magic goto here doesn't work because the localized version # of $^W is backed out before the transfer. return Getopt::Long::GetOptions(@_); } sub init { my (@arg); # Unbuffer since I generate little output, it's line oriented, and # I'll often be outputting to a log file or pipe. $| = 1; configure_getopt; getopt -bundle, @Option_once, @Option_repeatable or usage if @ARGV; defined $Host or xdie "no --host specified\n"; if (defined $Password_fd) { if ($Password_fd == fileno STDIN) { $Password = ; } else { open PASSWORD, "<&=$Password_fd" or xdie "can't fdopen $Password_fd to read password:"; $Password = ; close PASSWORD or xdie "error closing fd $Password_fd:"; } defined $Password or xdie "can't read password from fd $Password_fd:"; chomp($Password); } @arg = ($Host); push @arg, Debug => 1 if $Debug; push @arg, Passive => $Force_passive if defined $Force_passive; verbose "open $Host"; $Ftp = Net::FTP->new(@arg) or xdie "can't connect to $Host: $@\n"; verbose "user ", defined $User ? $User : 'anonymous'; @arg = ($User, $Password, $Account); pop @arg while @arg && !defined $arg[-1]; $Ftp->login(@arg) or ftp_die "can't login to $Host"; } sub main { init; @ARGV or xdie "no files specified\n"; while (@ARGV) { if ($ARGV[0] =~ /^-/) { getopt -bundle, @Option_repeatable or xdie "aborting\n"; @ARGV or xdie "non-sensical trailing switches specified\n"; next; } if (defined $Transfer_type) { verbose "type $Transfer_type"; $Ftp->type($Transfer_type) or ftp_die "can't set transfer type to $Transfer_type"; $Transfer_type = undef; } if (@Dir) { for (@Dir) { verbose "cd $_"; $Ftp->cwd($_) or ftp_die "can't chdir to $_"; } @Dir = (); } @As > 1 and xdie "multiple --as switches given without", " intervening filename\n"; my $local = shift @ARGV; my $remote = @As ? shift @As : $Full_path ? $local : basename $local; my $remote_base = basename $remote; my $remote_diff = $remote ne $local; if ($Tmp_strategy == TMP_NONE) { verbose "put $local", $remote_diff ? " $remote" : ''; defined $Ftp->put($local, $remote) or ftp_die "error storing $local", $remote_diff ? " as $remote" : ''; } elsif ($Tmp_strategy == TMP_SAMEDIR) { my $remote_dir = dirname $remote; my $tmp_want = ($remote_dir ne '.' ? "$remote_dir/" : '') . "tmp.$remote_base"; verbose "put_unique $local $tmp_want"; defined(my $tmp_got = $Ftp->put_unique($local, $tmp_want)) or ftp_die "error storing $local as $tmp_want uniquely"; verbose "rename $tmp_got $remote"; $Ftp->rename($tmp_got, $remote) or ftp_die "error renaming $tmp_got to $remote"; } elsif ($Tmp_strategy == TMP_FORMAT) { my $tmp_want = sprintf $Tmp_format, $remote_base; verbose "put $local $tmp_want"; defined($Ftp->put($local, $tmp_want)) or ftp_die "error storing $local as $tmp_want"; verbose "rename $tmp_want $remote"; $Ftp->rename($tmp_want, $remote) or ftp_die "error renaming $tmp_want to $remote"; } else { xdie "invalid \$Tmp_strategy $Tmp_strategy\n"; } if ($Ls) { my @l = $Ftp->dir($remote); if (!@l) { xwarn "no data returned doing dir of $remote\n"; } else { print join "\n", @l, ''; } } } return 0; } END { if (defined $Ftp) { verbose 'quit'; $Ftp->abort; unless ($Ftp->quit || $Ignore_quit_failure) { ftp_warn "error logging out from $Host"; $? ||= 1; } } } $Exit = main || $Exit; $Exit = 1 if $Exit && !($Exit % 256); exit $Exit; __END__ =head1 NAME ftp-upload - batch transfer local files to an FTP server =head1 SYNOPSIS B [I]... {[I]... I...}... =head1 DESCRIPTION B is used to send local files to an FTP server. It isn't interactive, it's meant to be used from scripts. It is disciplined about its exit value and it doesn't output informational messages by default. There are two kinds of switches. Initial switches have to appear before any filenames, they affect the session as a whole. Repeatable switches can appear interspersed with the file names, they affect the transfer of the files which appear after them on the command line. =head1 OPTIONS =head2 Initial switches These have to be used before any file names listed on the command line. =over 4 =item B<--debug> Turn debugging on. =item B<--help> Show the usage message and die. =item B<--ignore-quit-failure> Don't complain or set a failure exit code just because the QUIT command fails. This can be necessary because some servers, in blatant disregard of RFC 959, close the command channel when you send them an ABOR command. =item B<-v>, B<--verbose> Print informational messages to stdout. =item B<--version> Show the version number and exit. =back =head2 Initial switches which specify connection information These also have to be used before any file names listed on the command line. They specify the information used to set up the FTP connection. =over 4 =item B<--account> I This specifies the account to be used when logging into the remote system. This is distinct from the user name used to log in. Few systems need this. There is no default. =item B<-h>, B<--host> I Specify the host to which to connect. There is no default, you have to specify this switch. =item B<--passive> Force the use of passive (PASV) transfers. Passive transfers are required with some firewall configurations, but if you have such you'd do better to configure Net::FTP so that it knows when to use them (see L). If you need to use passive transfers with certain (broken) servers, however, this switch is your best bet. Alternatively, you can set $FTP_PASSIVE to 1 in the environment (see L). =item B<--no-passive> Force the use of active mode transfers. Active mode is the default so this is only required if your Net::Config or $FTP_PASSIVE turn passive mode on. =item B<--password> I This gives the password which will be used to login. The default is your email address. Note that you should not specify a real (secret) password this way, as on most systems anybody on the machine can see the arguments you pass to your commands. Use one of other password-setting switches instead. =item B<-s>, B<--password-stdin> This tells B to read the password from standard input. No prompt will be printed, and a single line will be read. Most people will use this switch to specify the password. Eg, echo 3x9sjJJh | ftp-upload -sh $host -u $user $file Using echo this way is safe where the B<--password> switch isn't if the echo command is built in to the shell. =item B<--password-fd> I This is like B<--password-stdin> except that it reads the password from the file descriptor numbered I. ftp-upload -h $host -u $user --password-fd=3 3<$pw_file $file =item B<-u>, B<--user> I Specify the user name to use when logging in. The default is C. =back =head2 Repeatable switches These switches can be used anywhere on the command line (except after the last file name). They affect the transfer of files listed after them. =over 4 =item B<--as> I Normally a file is transferred using the same name it has locally. If you use this switch the next file transferred will be called I on the other host instead. ftp-upload --host $host --as index.htm index.html =item B<-a>, B<--ascii> Perform transfers in ASCII mode. =item B<-b>, B<--binary> Perform transfers in binary mode. This is the default. =item B<-d>, B<--dir> I Change directory to I on the FTP server before continuing. You can use this multiple times between files, B will chdir once for each time you specify it. Using C<..> as the I will cause an FTP C to be done rather than a C. =item B<--full-path> Normally uploaded files go into the current directory on the remote host, even when the local file name given contains slashes. Eg, if you say ftp-upload -h $host /etc/motd B will upload the file as F, not F. This differs from how the standard B program works, and it also differs with how B worked before version 1.3. If you specify B<--full-path>, you'll get the other behavior. A request to upload F will tell the server to store F rather than F. When you use B<--as> the B<--full-path> setting doesn't matter. B<--full-path> only tells the program what name to use when it's choosing the name. =item B<--no-full-path> Disable B<--full-path>. This is the default. =item B<-l>, B<--ls> Try to get a remote directory listing of files after transferring them. I say "try" because there's no guaranteed way to do this with the FTP protocol. The command I run is C>. This will generally work if I doesn't contain any special characters. =item B<-L>, B<--no-ls> Disable the B<--ls> behavior. =item B<--tmp-none> Transfer files directly, don't do anything special to try to ensure that they don't appear under their real names on the remote machine until the transfer is finished. Each file is transferred with a single simple C. This is the default. =item B<--tmp-samedir> Transfer files to the remote machine using a temporary name, then rename them when the transfer finishes. This won't work if the remote server doesn't give a recognizable response to the C command. If the server's response to C isn't recognized by Net::FTP but is reasonable, Graham Barr might be willing to change Net::FTP to recognize it. If you like you can send the C<--debug> output to me and I'll coordinate such requests. =item B<--tmp-dir> I Transfer files to I on the remote host, then rename them when the transfer is complete. This is safer than B<--tmp-samedir> because it doesn't use C and so it works with more servers. ftp-upload -h $host --tmp-dir incoming $file =item B<--tmp-format> I Transfer files to C, I)>, then rename them when the transfer is complete. Like B<--tmp-dir>, this is safer than B<--tmp-samedir> because it doesn't use C and so it works with more servers. ftp-upload -h $host --tmp-format tmp.%s $file =back =head1 AUTHOR Roderick Schertler =cut ftp-upload-1.6/MANIFEST.SKIP0000664000175000000620000000012106657411177015025 0ustar roderickstaff# $Id: MANIFEST.SKIP,v 1.1 1999/02/07 22:23:59 roderick Exp $ ,v$ ~$ ^Makefile$ ftp-upload-1.6/TODO0000664000175000000620000000027710406272226013616 0ustar roderickstaff$Id: TODO,v 1.1 2006-03-16 14:22:14 roderick Exp $ - option like rsync's --relative to recreate the local directory structure on the remote side (idea from Andras Galos ) ftp-upload-1.6/README0000664000175000000620000000266306657413407014022 0ustar roderickstaffThis is the ftp-upload distribution. ftp-upload transfers local files to another machine using FTP. It's meant to be used by scripts and such rather than interactively. There's no user interface, the program is controlled strictly via the command line. It is disciplined with its exit status. The change log is in debian/changelog. Other than this you'll probably want to ignore the contents of the debian subdirectory, it contains the files which turn the distribution into a Debian package. The program can be installed in the usual manner: perl Makefile.PL make install Roderick Schertler Copyright (C) 1999 Roderick Schertler. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. For a copy of the GNU General Public License write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA On Debian systems, the complete text of the GNU General Public License can be found in `/usr/doc/copyright/GPL'. $Id: README,v 1.2 1999/02/07 22:43:19 roderick Exp $ ftp-upload-1.6/MANIFEST0000664000175000000620000000025406657411176014266 0ustar roderickstaff $Id: MANIFEST,v 1.1 1999/02/07 22:23:58 roderick Exp $ MANIFEST MANIFEST.SKIP Makefile.PL README debian/changelog debian/control debian/copyright debian/rules ftp-upload