Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Perl die after executing external program

by mr_mischief (Monsignor)
on Apr 28, 2011 at 20:11 UTC ( [id://901867]=note: print w/replies, xml ) Need Help??


in reply to Perl die after executing external program

Backticks don't capture STDERR. You'd need to redirect STDERR on top of STDOUT for lftp as lftp uses STDERR for much of its interface.

Try this:

my $CLIENT = "lftp"; my $connectionString = "" . $CLIENT . " -d -f script.ftp 2>&1"; my $result = `$connectionString` or die "\nERROR running $CLIENT: $!"; return $result;

I make no guarantees, but I did install lftp just to test this theory and look at this which shows STDERR being used:

[chris@pineapple ss64]$ >bar [chris@pineapple ss64]$ lftp -d -f foo > bar ---- Resolving host address... ---- 1 address found: 64.131.79.110 Password: [chris@pineapple ss64]$ cat bar [chris@pineapple ss64]$ lftp -d -f foo > bar 2>&1 Password: [chris@pineapple ss64]$ cat bar ---- Resolving host address... ---- 1 address found: 64.131.79.110 [chris@pineapple ss64]$

As a side note, I hope you're using SFTP or HTTPS (both of which modern versions of lftp support) if you're not using an anonymous connection. I don't use plain-text FTP with authenticated accounts, and I recommend others don't. Without getting into too many specifics about statistics, let's say it's common in the security department of a web hosting company to deal with customers whose hosting account credentials were stolen by malware or sniffing. It may be a small portion of customers who ever have a breach, but compromised passwords are a fairly common sort of breach. Use SFTP or scp if you can, and use HTTPS when possible if logging into a web app you actually care a lot about.

BTW, none of this is really Perl-specific beyond 'Backticks don't capture STDERR.'. Then again, those backticks are reminiscent of shell backticks which work the same way, so that's not even that Perl-specific.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-25 13:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found