Title: RE: FTP modules

See below



-----Original Message-----
From: Kelly Stumbaugh [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 28, 2005 12:13 PM
To: [email protected]
Subject: FTP modules


Does anyone running Perl on Windows recommend a module for FTP?  I have
tried Net::FTP::Common, but I can't get it to work and there isn't much
in the way of documentation.  If you have some sample code that
retrieves a file from an FTP site, it would be really helpful for me to
see it.  Thanks! _______________________________________________
Perl-Win32-Users mailing list [email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


It's a modified extract from a script I had, but you can get the idea. 

#! perl -w

use File::Copy;
use File::Path;
use Net::FTP;

($user, $pwd, $ipaddress) = @ARGV;
$whereto="C:/";
$current="";
$date = time();
($sec, $min, $hour, $day, $mon, $year) = localtime $date;
$sec = 0;
$min = 0;
$hour = 0;
$year = $year + 1900;
$mon++;
$current=$year.$mon.$day;
mkpath ($whereto.$current, 0, 0777);
$host="$ipaddress";
$reports="Reports";

$ftp=Net::FTP->new($host,Timeout=>240) or $newerr=1;
$ftp->login("$user","$pwd") or $newerr=2;
$ftp->cwd($reports) or $newerr=3;
$ftp->binary;
@files = $ftp->ls();
for(@files){
            $ftp->get($_, $whereto.$current."/".$_);
            }
$ftp->cwd("../Data");
@datafiles = $ftp->ls();
for(@datafiles){
  $ftp->get($_, "G:/".$_);
}

_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to