Liza Das wrote:
> I'm trying to finish this script which should upload files
> to a secure ftp site.
> 
> When I removed the win32::autoglob, the script doesn't read
> the path or the files passed in the @filemask.
> 
> When I added it back in, it only captures what I had passed, ex:
> c:\test\*.txt
> But what I want to use it as is a file list. So I would like it to have
> a list of files such as:
> test1.txt
> test2.txt
> test3.txt
> 
> Please help.

This should work with or without Autoglob:

#!/usr/bin/perl

use strict;
use warnings;
use Net::FTPSSL;
# use Win32::Autoglob;
use File::Copy;
use File::Basename;

my $ftpaddress = shift;         # Example: ftp.ftptest.com
my $username = shift;           # Example: ftptest
my $password = shift;           # Example: test123
# my $port = shift;             # Example: 990
my port = 990;                  # hardcode 990
my $remotedir = shift;          # Example: upload
my $newpath = shift;            # Example: c:/ftp/uploaded
my @filemask = @ARGV;           # Example: c:/ftp/test*, ...

print "************************BEGIN FTP LOG*******************************\n";

my $ftps = Net::FTPSSL->new($ftpaddress, Port => $port, Encryption => 'I',
  Debug => 0) or die "new FTPSSL $ftpaddress: $!($^E)";
$ftps->login($username, $password) or die "login failed: $!($^E)";
$ftps->binary;
$ftps->cwd($remotedir) or die "cwd $remotedir: $!($^E)";

foreach (@filemask) {
        foreach my $file (glob $_) {
                print "Uploading $file\n";
                $ftps->put($file) or die "put $file: $!($^E)";
                print "Moving $file to $newpath\n";
                move ($file, $newpath) or die "move ($file, $newpath)";
        }
}

print "File uploads completed\n";
$ftps->quit();

print "*************************END FTP LOG********************************\n";

__END__
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to