> --0-1181151836-1101950943=:60409 > Content-Type: text/plain; charset=us-ascii > > > I'm very new to perl, can any share an example ftp script? I need to > ftp from one server directory to another server to a > directory >
first, read the following: perldoc Net::FTP #!/usr/bin/perl use strict; use warnings; # # Write a trivial FTP application # use Net::FTP; # # open a connection to some host (I need passive mode here # to get around my firewall, you may not, which case you # can leave it out ) # my $ftp = Net::FTP->new('your-host.com', Passive => 1) || die "Cannot connect to host: $@"; warn"Connection made...."; # # send a username and password (if you want to use anonymous, be a mensch # and send an email address as password ) # $ftp->login('your-username', 'your-password' ) || die "Could not login", $ftp->message ; warn "Login complete... "; # # the default transfer mechanims is 'aware' of ASCII # and will 'fix' line endings to match local convention. # If you are moving some file that is NOT textual, # you will want to set binary mode. $ftp->binary || die "Could not set binary mode", $ftp->message; warn "Bin mode set ... " ; # # Now we are ready to get the file we want # $ftp->get('random_file.jpg') || die "Get failed ", $ftp->message; warn "Get complete ... "; # # and clean up after ourselves # $ftp->quit; -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Lawrence Statton - [EMAIL PROTECTED] s/aba/c/g Computer software consists of only two components: ones and zeros, in roughly equal proportions. All that is required is to sort them into the correct order. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>