<DBSMITH <at> OhioHealth.com> writes:

..snip..

I'm fairly new to Perl, but have been working on a similar typ problem and
monitoring the success of my Net::FTP session.  I used logic similarm to the
following:

my ftp;
if($ftp = Net::FTP->new($remotehost)) {
   print "Initial FTP successful\n";
} else {
   print "Initial FTP failed\n"; die; }
if($ftp->login($user, $pass)) {
   print "Login Successful\n";
} else {
   print "Login failed!\n"; die; }
if($ftp->ascii()) {
   print "Mode set to ASCII successful\n";
} else {
   print "Mode set to ASCII failed\n"; die; }
if($ftp->cwd($remotedir)) {
   print "Change working directory successful\n";
} else {
   print "Change working directory failed\n"; die; }
if($ftp->put($data)) {
   print "Put was successful\n"; 
} else {
   print "Put failed\n"; die; }
if($ftp->quit) {
   print "FTP session terminated successfully\n";
} else {
   print "FTP session termination failed\n"; die; }

You can add to or remove as much logging as desired. I used it this way for a
script that a non-technical user would be running so that when it failed, I wold
know why if failed. You could also set it up as a series of cascading elsif's as
well. If you want to produce a log file that is redirected somewhere else other
than stdout, open up a filehandle and direct your prints to it. Hode this helps.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to