note 71766 deleted from function.ssh2-fetch-stream by colder
| From: | colder@php.net | Date: | Fri, 15 Dec 2006 12:38:24 +0000 |
| Subject: | note 71766 deleted from function.ssh2-fetch-stream by colder | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-120633@lists.php.net to get a copy of this message | ||
Note Submitter: ricardophp at yahoo com br
----
Sweet toy!
Could not make it work with fwrite like webmaster at spectreanime dot com shows at the ssh2_shell
help page, althought i got it working this way
<?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);
?>
which shows as ...
Connexion SSH [OK]
Authentification [OK]
Erros encontrados!
------------
bash: line 1: /bin/lssss: No such file or directory
------------