perlpal has asked for the wisdom of the Perl Monks concerning the following question:

Hi Perl Monks,

I use the $? variable for the status returned by the last backtick command on a local system.

However when i execute a command on a remote system via say ssh or telnet (using corresponding perl modules) , how do i get the execution status of the command ?

Thanks in advance

Replies are listed 'Best First'.
Re: Remote command execution status
by cdarke (Prior) on Feb 25, 2010 at 10:27 UTC
    The man pages for ssh gives:
    ssh exits with the exit status of the remote command or with 255 if an error occurred.

    The doc for Net::SSH::Perl says:
    ($out, $err, $exit) = $ssh->cmd($cmd, [ $stdin ])Runs the command $cmd on the remote server and returns the stdout, stderr, and exit status of that command.

    For telnet, my man pages do not document a return code (!), whereas Net::Telnet has a large section devoted to errmode, which you might like to read.
Re: Remote command execution status
by moritz (Cardinal) on Feb 25, 2010 at 10:15 UTC
    However when i execute a command on a remote system via say ssh or telnet (using corresponding perl modules) , how do i get the execution status of the command ?

    From the module you use for executing the command, if it supports that operation. Since you haven't told us which modules you use, I can't give a more specific answer.

    Perl 6 - links to (nearly) everything that is Perl 6.