in reply to Re: Perl (Net::SSH::Perl) script sometimes hangs while running remote command but shell script works
in thread Perl (Net::SSH::Perl) script sometimes hangs while running remote command but shell script works

Thanks for the help salva! As far as debugging the script (when it hangs) is concerned, I’ll use strace.

For the issue where bash was printing error message but my perl script wasn’t, I figured out the mistake I was committing. Instead of

my ($stdout) = $ssh->capture2("~/release/$wrapper");

I should have used

my ($stdout, $errput) = $ssh->capture2("~/release/$wrapper");

I was only checking stdout earlier :)

  • Comment on Re^2: Perl (Net::SSH::Perl) script sometimes hangs while running remote command but shell script works
  • Select or Download Code

Replies are listed 'Best First'.
Re^3: Perl (Net::SSH::Perl) script sometimes hangs while running remote command but shell script works
by Technext (Acolyte) on Jul 01, 2015 at 18:33 UTC

    There is one issue that i noticed today. If i use the following code, it dies after printing error message. Obviously, the stdout will not be printed

    die "Error: $errput\n" if $errput; printf "Output: $stdout\n" if $stdout;
    Problem is when i reverse the lines as shown below, it prints the output and then dies but does not print the error message.
    printf "Output: $stdout\n" if $stdout; die "Error: $errput\n" if $errput;
    How can i make it print the stdout and the error message both?