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.
In reply to Re: Perl die after executing external program
by mr_mischief
in thread Perl die after executing external program
by aullah
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |