note 82109 deleted from function.ssh2-sftp-stat by langemeijer
| From: | langemeijer@php.net | Date: | Sun, 25 Nov 2012 06:32:08 +0000 |
| Subject: | note 82109 deleted from function.ssh2-sftp-stat by langemeijer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-192140@lists.php.net to get a copy of this message | ||
Note Submitter: vanscot on gemail
----
for some unkwon reason, stream_set_timeout() does not work on ssh2_exec, and strem_set_blocking (on
my personal case) just hangs the script until it hits the max_execution_time.
Using sleep() or usleep() does not help either, because they are arbitrary and the command passed to
ssh2_exec may have not finished yet.
The (best?) way to workaround this case was using a sh script on the remote server an a file as a
handshake, the using this function to stat the file and, given a certain rule, fetching the result
using stream_get_contents().
The sh script should create a dummy not zero size file (the handshake), run the commands then
truncate the file (finished execution of the command). On the other side, the php script, should be
stating the file until it gets a 0 size and then fetch the results.
I hope that this would be usefull to somebody else until stream_set_timeout() works on ssh2_exec or
the functions adds a "timeout" parameter.