Hi,
I try to use SSH2 in PHP to connect to a linux server. Here is the
code:
<pre>
$connection = ssh2_connect('x xx', 22);
if( !$connection ) die("Failed to connect");
if( ! ssh2_auth_passw ord($connection , 'aaa', 'bbb') )
die("FAIL");
$s = ssh2_shell($con nection, "vt100");
if( !$s ) die("Can not attach stdio.");
fwrite($s, "ls /tmp");
$o = fread($s, 100);
echo $o;
</pre>
But I can't get any output using fread. How can I get the
output(STDOUT)?
Any help is appreciated! Thanks in advance.
Have a nice day!
Regards
KEN
I try to use SSH2 in PHP to connect to a linux server. Here is the
code:
<pre>
$connection = ssh2_connect('x xx', 22);
if( !$connection ) die("Failed to connect");
if( ! ssh2_auth_passw ord($connection , 'aaa', 'bbb') )
die("FAIL");
$s = ssh2_shell($con nection, "vt100");
if( !$s ) die("Can not attach stdio.");
fwrite($s, "ls /tmp");
$o = fread($s, 100);
echo $o;
</pre>
But I can't get any output using fread. How can I get the
output(STDOUT)?
Any help is appreciated! Thanks in advance.
Have a nice day!
Regards
KEN
Comment