note 103453 deleted from function.ssh2-exec by danbrown
| From: | danbrown@php.net | Date: | Thu, 14 Apr 2011 15:01:07 +0000 |
| Subject: | note 103453 deleted from function.ssh2-exec by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-178840@lists.php.net to get a copy of this message | ||
Note Submitter: Michele Bonera
----
Please notice that there is undocumented feature in ssh2_exec to fetch the exit status of the
submitted command:
<?php
// Opening connection
$connection = ssh2_connect('remotehost', 22);
ssh2_auth_password($connection, 'user', 'pass');
// Sumbitting command
$stream = ssh2_exec($connection, 'test_command.sh');
$errorStream = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR);
// Enable blocking for both streams
stream_set_blocking($errorStream, true);
stream_set_blocking($stream, true);
// Getting exit status
$exitStatus = ssh2_get_exit_status($stream);
echo "Exit status is: $exitStatus";
?>