Posted By

kkindoh on 07/19/06


Tagged

Net FTP


Versions (?)

Who likes this?

6 people have marked this snippet as a favorite

jkochis
hxseven
fugue
avances123
jamessullenriot
icecreamboyy


Net::FTP to ftp a file


 / Published in: Perl
 

Simple way to do ftp from Perl

  1. use Carp;
  2. use Net::FTP;
  3.  
  4. my $ip = ...; # Target machine
  5.  
  6. my $local= ...; # local filename
  7. croak "$local file is missing !!\n" unless -f $local;
  8.  
  9. my $remote= ...; # Remote filename
  10.  
  11. my $ftp= Net::FTP->new( $ip
  12. ,Port => 21 # Standard port number
  13. ,Timeout => 15 # Timeout in seconds
  14. )
  15. or croak "Failed to connect to $ip.";
  16.  
  17. my $user= ...; # login user
  18. my $pw = ...; # login password
  19. $ftp->login( $user, $pw )
  20. or croak "Failed to login.";
  21.  
  22. $ftp->put( $local, $remote)
  23. or croak "Failed to ftp.";
  24.  
  25. $ftp->quit();

Report this snippet  

You need to login to post a comment.