[Ssh-sftp-perl-users] Net::SSH2, how to get exit_status
Brought to you by:
dbrobins
From: Pierrick LE G. <pie...@le...> - 2007-04-17 16:52:21
|
Hi, Using Net::SSH2 I would like to get the exit status of my last remote command, how can I do this? I've read Net::SSH2::Channel perldoc several times but no example is given, and I really need one. The following code sample does not work: my $chan = $ssh2->channel(); $chan->ext_data('merge'); $chan->shell(); print $chan 'perl /home/z0rglub/work/talend/outerr2.pl; echo $?', "\n"; @output = map {chomp; $_} <$chan>; $exit_status = $chan->exit_status(); print join("\n", map {'command 1: '.$_} @output), "\n"; print '$exit_status: ', $exit_status, "\n\n"; The output is: command 1: warning 1 command 1: warning 2 command 1: salut 1 command 1: 10 $exit_status: 0 And of course, I would like the $exit_status to be 10. Bye -- Pierrick LE GALL R&D engineer at Talend, Open data solution http://www.talend.com |