Ok, so pecl ssh2 is supposedly a wrapper for libssh2. Libssh2 has libssh2_channel_get_exit_status. Is there any way to get this information?
I NEED:-stdout-STDERR-EXIT STATUS
I only get exit status. Many people throw around phplibsec when ssh is brought up, but I see no way to get stderr or channel exit status from this: / Has anyone been able to get all three?
So, first the first:NO, they did not implement libssh2_channel_get_exit_status. What for? Beyond meHere is what the identifier did:
$command .= ';echo -e "\n$?"'
$? exec. ? . , , . $returnValue stdout. , - , . . 30 , , ssh .
Rapzid . ssh2 php- . ssh, .
function exec( $command ) { $result = $this->rawExec( $command.';echo -en "\n$?"' ); if( ! preg_match( "/^(.*)\n(0|-?[1-9][0-9]*)$/s", $result[0], $matches ) ) { throw new RuntimeException( "output didn't contain return status" ); } if( $matches[2] !== "0" ) { throw new RuntimeException( $result[1], (int)$matches[2] ); } return $matches[1]; } function rawExec( $command ) { $stream = ssh2_exec( $this->_ssh2, $command ); $error_stream = ssh2_fetch_stream( $stream, SSH2_STREAM_STDERR ); stream_set_blocking( $stream, TRUE ); stream_set_blocking( $error_stream, TRUE ); $output = stream_get_contents( $stream ); $error_output = stream_get_contents( $error_stream ); fclose( $stream ); fclose( $error_stream ); return array( $output, $error_output ); }