note 53575 deleted from function.ssh2-exec by bjori
| From: | bjori@php.net | Date: | Mon, 24 Apr 2006 22:21:09 +0000 |
| Subject: | note 53575 deleted from function.ssh2-exec by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-109616@lists.php.net to get a copy of this message | ||
Note Submitter: mao at nospam dot com
----
As per the documentation, this function returns a resource of type stream. I expected stream
functions, including feof(), to work with the resource, but the following did not seem to work for
me:
<?php
$filename = "eg.txt";
$stream0 = ssh2_exec($conn, "stat $filename");
if($stream0) {
$i = 1;
while( !feof($stream) ) {
$line = fgets($stream0)
echo "<br>Line $i ==> $line";
$i += 1;
}
?>
Instead, I used the following and it worked!
<?php
$filename = "eg.txt";
$stream0 = ssh2_exec($conn, "stat $filename");
if($stream0) {
$i = 1;
while( $line = fgets($stream0) ) {
echo "<br>Line $i ==> $line";
$i += 1;
}
?>