ochi Posted March 8, 2010 Share Posted March 8, 2010 Hello, I'm using the ssh2 for php, but, I cant read the response from the remote host: $con = ssh2_connect("xx.xx.xx.xx", $port) or die ("No conection"); $autent = ssh2_auth_password($con, $_SESSION['user'], $_SESSION['pass']) or die ("No conection"); $stream = ssh2_exec($con,'ls -la'); stream_set_blocking( $stream, true ); $data = ""; while( $buf = fread($stream,4096) ){ $data .= $buf; } echo $data; fclose($stream); But the while is always false. I tried executing : mkdir hello and it worked, so, is not a problem with the conection. Thank you very much for your help! Regards Link to comment https://forums.phpfreaks.com/topic/194491-ssh-extension/ Share on other sites More sharing options...
ochi Posted March 8, 2010 Author Share Posted March 8, 2010 I solved it! I changed the while: stream_set_blocking($stream, true); $output = stream_get_contents($stream,-1); My problem now is another one, I opened the ssh connection to execute the mplayer, so, my page is blocked because it's receiving the stream. Do you know how can I solve it? Thanks! Regards! Link to comment https://forums.phpfreaks.com/topic/194491-ssh-extension/#findComment-1022993 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.