Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: Perl die after executing external program

by mr_mischief (Monsignor)
on Apr 29, 2011 at 12:51 UTC ( #901972=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Perl die after executing external program
in thread Perl die after executing external program

I see you replied to Re: Perl die after executing external program after I posted Re: Perl die after executing external program but did you bother to read what I typed? You're already capturing STDOUT of the process. You also need to capture STDERR, because that's where the output you want goes.

Yes, it really is that simple. Differences in account permissions are always a relatively good guess about differences in how programs operate, but a good guess is still a guess. Which file descriptor lftp uses for output doesn't change depending on which account is running the program. Which one you need to capture does change depending on which one is being written to in the executed program.

2>&1 is your friend.


Comment on Re^3: Perl die after executing external program
Download Code
Re^4: Perl die after executing external program
by aullah (Initiate) on Apr 29, 2011 at 13:09 UTC
    Yes, I did tried to capture the STDERR but nothing written there. Empty.

      That's odd. This code works for me:

      my $CLIENT = "lftp"; my $connectionString = "" . $CLIENT . " -d -f bar 2>&1"; my $result = `$connectionString` || die "\nERROR running $CLIENT: $!"; print $result;

      The return won't work because this isn't part of a subroutine, but you should get an error about that specifically if this is really the code you're running and it ever makes it past the die. Also, my script file was called 'bar' rather than script.ftp in this case.

      Are you sure lftp is in your path when the program is run? You might have to supply the full path.

        Yes, I'm sure because I can see the output on terminal while executing the code with debugging ON. But problem is STDOUT/STDERR is not returning any value except 0.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2014-12-27 14:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls