#!/usr/local/bin/perl -s # # Put a file using ftp. # # ftpput host source dest # puts file, logging in as anonymous with user@host password (default) # ftpput user@host source dest # puts file as user "user" and prompts for password # # Written by Gene Spafford # Last update, 17 May 1994, D. Sundstrom # require "ftplib.pl"; die "usage: ftpput [-ascii] [] where may be of the form user@host remote user defaults to 'anonymous' if not specified " unless ($#ARGV > 0 && $#ARGV < 3); ($Host, $Source, $Dest) = @ARGV; if ($Host =~ /^(\S+)@(\S+)$/) { # user@host format? ($User, $Host) = ($1, $2); print STDERR "Password to use: "; system 'stty -echo'; chop($Pass = ); system 'stty echo'; print STDERR "\n"; } die "Cannot transfer a directory.\n" if -d $Source; &ftp'open($Host, $User, $Pass) || &fail; &ftp'type($ascii ? "a" : "i") || &fail; &ftp'put($Source, $Dest) || &fail; &ftp'close; sub fail { $save = &ftp'error; &ftp'close; die $save; }