用Perl寫的FTP客戶端程序

#!/usr/bin/perl



#ok, let's begin.
use Net::FTP;

#set some variables
$host = "10.20.30.40";
$user = "username";
$pass = "password";
$path = "/home/mengge/testpath";

#login to host && change cwd
my $ftp = new Net::FTP($host);
$ftp->login($user,$pass) || die "Error on logging in : $!";
$ftp->cwd($path) || die "Error on changing directory : $!";

#list files in the cwd
my @AllFiles = $ftp->ls();
foreach my $file (@AllFiles)
{
print "$file/n";
}

#after list, quit
$ftp->quit();

#end of this script.
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章