By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,408 Members | 1,576 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,408 IT Pros & Developers. It's quick & easy.

get output from ssh2_shell

P: n/a
Hi,
I try to use SSH2 in PHP to connect to a linux server. Here is the
code:
<pre>
$connection = ssh2_connect('xxx', 22);
if( !$connection ) die("Failed to connect");

if( ! ssh2_auth_password($connection, 'aaa', 'bbb') )
die("FAIL");

$s = ssh2_shell($connection, "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

Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
ke****@gmail.com wrote:
fwrite($s, "ls /tmp");

$o = fread($s, 100); But I can't get any output using fread. How can I get the
output(STDOUT)?


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.

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.