get output from ssh2_shell

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

   I try to use SSH2 in PHP to connect to a linux server. Here is the
$connection = ssh2_connect('xxx', 22);
if( !$connection ) die("Failed to connect");

if( ! ssh2_auth_password($connection, 'aaa', 'bbb') )

$s = ssh2_shell($connection, "vt100");
if( !$s ) die("Can not attach stdio.");

fwrite($s, "ls /tmp");

$o = fread($s, 100);
echo $o;

  But I can't get any output using fread. How can I get the
  Any help is appreciated! Thanks in advance.
  Have a nice day!


Re: get output from ssh2_shell wrote:
Quoted text here. Click to load it

That's because you didn't tell the shell to do somehting, you only send
some characters... Try appending "\n" to tell the shell to execute
received chars.

Site Timeline