sub ftp_load {
my ($server, $dir, @files) = @_;
my $ftp = Net::FTP->new($server);
unless (defined($ftp)) {
msg("Unable to setup FTP connection to $server");
return 0;
}
unless ($ftp->login("anonymous", "$cmdname@")) {
msg("Unable to login on FTP server $server");
$ftp->quit;
return 0;
}
unless ($ftp->cwd($dir)) {
msg("Unable to cd $dir on FTP server $server");
$ftp->quit;
return 0;
}
foreach my $file (@files) {
msg("Loading $file...");
unless ($ftp->get($file)) {
msg("Loading $file... FAILED"); $ftp->quit;
return 0;
}
chmod(0755, $file) if $file =~ /\.pl$/;
msg("Loading $file... OK");
}
msg("Loading finished successfully");
$ftp->quit;
return 1;
}
|