Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Net::FTP Help

by beebware (Pilgrim)
on Mar 01, 2002 at 17:39 UTC ( [id://148622]=note: print w/replies, xml ) Need Help??


in reply to Net::FTP Help

Try:
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://148622]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2025-02-17 01:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found