note 71830 added to function.ssh2-fetch-stream
| From: | (ricardophpyohoocombr) | Date: | Mon, 18 Dec 2006 15:41:33 +0000 |
| Subject: | note 71830 added to function.ssh2-fetch-stream | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-120747@lists.php.net to get a copy of this message | ||
I got a friend using those functions and he was not able to use this ssh2_fetch_stream function.
First of all I got the ssh2_shell sample by webmaster at spectreanime dot com, but this function
does not work with his sample, i believe thats because he use fwrite instead of ssh2_shell or
ssh2_exec to run the command.
This sample below is to run under a command line and is fully functional. note that i add the sleep
as advised by webmaster at spectreanime dot com
<?php
echo "Connexion SSH ";
if (!($connection=@ssh2_connect("69.69.69.69", 22))) {
echo "[FAILED]\n";
exit(1);
}
echo "[OK]\nAuthentification ";
if (!@ssh2_auth_password($connection,"root","YourPassword")) {
echo "[FAILED]\n";
exit(1);
}
echo "[OK]\n";
$stdout_stream = ssh2_exec($connection, "/bin/lssss -la /tmp");
sleep(1);
$stderr_stream = ssh2_fetch_stream($stdout_stream, SSH2_STREAM_STDERR);
echo "Erros encontrados!\n------------\n";
while($line = fgets($stderr_stream)) { flush(); echo $line."\n"; }
echo "------------\n";
while($line = fgets($stdout_stream)) { flush(); echo $line."\n";}
fclose($stdout_stream);
?>
----
Server IP: 200.185.126.100
Probable Submitter: 200.175.3.170
----
Manual Page -- http://www.php.net/manual/en/function.ssh2-fetch-stream.php
Edit -- https://master.php.net/note/edit/71830
Del: integrated -- https://master.php.net/note/delete/71830/integrated
Del: useless -- https://master.php.net/note/delete/71830/useless
Del: bad code -- https://master.php.net/note/delete/71830/bad+code
Del: spam -- https://master.php.net/note/delete/71830/spam
Del: non-english -- https://master.php.net/note/delete/71830/non-english
Del: in docs -- https://master.php.net/note/delete/71830/in+docs
Del: other reasons-- https://master.php.net/note/delete/71830
Reject -- https://master.php.net/note/reject/71830
Search -- https://master.php.net/manage/user-notes.php