open(STDOUT, ">>$logpath") or die "Cannot redirect STDOUT: $!";
open(STDERR, ">>$logpath") or die "Cannot redirect STDERR: $!";
Any errors or screen output therefore produced will be pushed to $logpath.
You might also find this section of code handy:
use Net::FTP;
# lets seperate any URL from the hostname
($host,$url)=split('/',$data{'FTPUrl'},2);
$ftp=Net::FTP->new($host,Debug=>1);
$results=$ftp->login($data{'FTPUsername'},$data{'FTPPassword'});
print "Mesage: ".$ftp->message()."\n";
if (!$results) {
$failedlog.="* Unable to login to remote FTP site ($host) with\n";
$failedlog.=" Username: $data{'FTPUsername'}\n";
$failedlog.=" Password: $data{'FTPPassword'}\n";
$failedlog.=" Error: ".$ftp->message()."\n";$failed=1;
print $failedlog;
}
print "Logged on using $data{'FTPUsername'}, $data{'FTPPassword'}\n"
+;
if (length($url)>1) { $ftp->cwd($url);print "Changed to $url\n"; }
$pwd=$ftp->pwd();
print "CWD is: $pwd\n";
$ftp->hash(STDOUT);
$ftp->binary;
print $ftp->ls;print "\n";
$results=$ftp->put($filepath,$filename
if (!$results) {
$failedlog.=" * Unable to uploaded $advert{$i.'-Advertname'})\n";
$failedlog.=" Error: ".$ftp->message()."\n";$failed=1;
$failedlog.=" Directory: $pwd\n";
}
$ftp->quit;
Use the STDERR and STDOUT logging above and you've got a full and complete track of what happened in the ftp upload etc. Then you just need to email the log file and the job's done. |