I'm trying to set an ftp script to upload files to an ftp site using net::ftpssl.
The problem I'm having is that if I have a list of files that need to be uploaded.
Below is the script I'm using, please help.
 
 
#!/usr/bin/perl -w
 
use Net::FTPSSL;
use Win32::Autoglob;
use File::Copy;
use File::Basename;
use Net::CMD;
 

my $ftpaddress;
my $username;
my $password;
my $port;
my $remotedir;
my $newpath;
my $filemask;
 
$ftpaddress = shift ( @ARGV ); # Example: ftp.ftptest.com
$username = shift  ( @ARGV ) ; # Example: ftptest
$password = shift   ( @ARGV ); # Example: test123
$port = shift (@ARGV);         # Example: 21
$remotedir= shift  ( @ARGV );  # Example: upload
$newpath = shift (@ARGV);      # Example: c:\ftp\uploaded
$filemask = glob  ( @ARGV );   # Example: c:\ftp\test*
 
print "***************************BEGIN FTP LOG**************************************\n"; 
 
my $ftps = Net::FTPSSL->new($ftpaddress,Port => $port,Encryption => 'E', Debug => 0)
              or die "Can't open $ftpaddress";
 
$ftps->login($username,$password)
      or die "Can't login, check username and password.\n";
 
$ftps->binary;
 
$ftps->cwd($remotedir) or die "Can't change directory.\n";
 
foreach my $filemask (@ARGV){
#print "$filemask\n";
$command = "dir $filemask /b";
$command2 = $command . "\n";
@myfile = `$command2`;
 
print "@myfile";
 
$ftps->put(@myfile,@myfile) or die "Can't upload file.\n";
 
# foreach my $test (@myfile) {
#    print "$test\n"; }
 
}
 
  #put(LOCAL_FILE,[REMOTE_FILE]); Stores the LOCAL_FILE into the remote ftp server.
  #LOCAL_FILE may be filehandle, but in this case REMOTE_FILE is required. Return undef if it fails.
 

$ftps->quit();
 
print "***************************END FTP LOG**************************************\n"; 
 
 
Thanks
Liza
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to