From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Liza Das Sent: 01 November 2006 14:44 To: [email protected] Subject: Help using Net::FTPSSL
> 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. But you don't say what the actual problem is? > Below is the script I'm using, please help. > > > #!/usr/bin/perl -w You should have "use strict;" here, and "use warnings;" is preferable to -w. > > use Net::FTPSSL; > use Win32::Autoglob; OK... > use File::Copy; > use File::Basename; > use Net::CMD; I can't see where any of the above modules are used. > > > my $ftpaddress; > my $username; > my $password; > my $port; > my $remotedir; > my $newpath; > my $filemask; > > $ftpaddress = shift ( @ARGV ); # Example: ftp.ftptest.com <ftp://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* Its better to declare and initialise variables at the same time, rather than declaring a bunch and then initialising them. Also, why are you calling glob if you are using Win32::Autoglob? > > 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`; my @myfile = `dir $filemask /b` would have done, or possibly my @myfile = <$filemask>. Also, its not clear why you are even doing this if you are using Win32::Autoglob. > > print "@myfile"; > > $ftps->put(@myfile,@myfile) or die "Can't upload file.\n"; Now that looks odd and not at all in accordance with the documentation (if things are not working as you expect, always check the documentation for the modules and functions that you use very carefully). What you are saying is 'put' the first file in @myfile to the remote server and give it the name of the second file in @myfile, except in the case where @myfile contains less than two entries. Something like the following might be more successful, assuming that @myfile contains a list of files to upload. foreach my $file (@myfile) { $ftps->put($file) or die "Failed to put $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"; HTH -- Brian Raven _________________________________________ The information contained in this e-mail is confidential and solely for the intended addressee(s). Unauthorised reproduction, disclosure, modification, and/or distribution of this email may be unlawful. If you have received this email in error, please notify the sender immediately and delete it from your system. The views expressed in this message do not necessarily reflect those of Atos Euronext Market Solutions. _________________________________________ ================================= Atos Euronext Market Solutions Disclaimer ================================= The information contained in this e-mail is confidential and solely for the intended addressee(s). Unauthorised reproduction, disclosure, modification, and/or distribution of this email may be unlawful. If you have received this email in error, please notify the sender immediately and delete it from your system. The views expressed in this message do not necessarily reflect those of Atos Euronext Market Solutions. L'information contenue dans cet e-mail est confidentielle et uniquement destinee a la (aux) personnes a laquelle (auxquelle(s)) elle est adressee. Toute copie, publication ou diffusion de cet email est interdite. Si cet e-mail vous parvient par erreur, nous vous prions de bien vouloir prevenir l'expediteur immediatement et d'effacer le e-mail et annexes jointes de votre systeme. Le contenu de ce message electronique ne represente pas necessairement la position ou le point de vue d'Atos Euronext Market Solutions. _______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
