Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Net::FTP Help

by muzakfetch (Scribe)
on Mar 01, 2002 at 02:43 UTC ( [id://148457]=perlquestion: print w/replies, xml ) Need Help??

muzakfetch has asked for the wisdom of the Perl Monks concerning the following question:

Hello fellow monks, I apologize for the simple question but google didnt find too much on this subject. I want to place all of the output from Net::FTP into a scalar so it can be emailed for confirmation. However, it seems that currently that output is sent to STDERR. Now I could be wrong but any help would be appreciated.

Humbly,
muzakfetch

Replies are listed 'Best First'.
Re: Net::FTP Help
by jlongino (Parson) on Mar 01, 2002 at 05:10 UTC
    Sometimes a Super Search can be more useful than Google. I Super Searched Words in text: using the keywords ftp::net log and came up with lots of hits. This one seems to be just what you're looking for.

    --Jim

Re: Net::FTP Help
by beebware (Pilgrim) on Mar 01, 2002 at 17:39 UTC
    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: perlquestion [id://148457]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-25 17:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found