note 56564 added to function.ssh2-exec
| From: | gakksimian at yahoo dot com | Date: | Wed, 07 Sep 2005 17:15:25 +0000 |
| Subject: | note 56564 added to function.ssh2-exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-94864@lists.php.net to get a copy of this message | ||
Executing remote Windows commands...
After some hair pulling, I thought I'd suggest a couple things that might help others:
1. Use 'ssh2_fetch_stream' to open a stderr stream according to the manual.
2. Windows shell commands require 'cmd /C [command]' to execute. (I had forgotten this)
<?php
// code fragment
$stdout_stream = ssh2_exec($connection, 'cmd /C dir');
$stderr_stream = ssh2_fetch_stream($stdout_stream, SSH2_STREAM_STDERR);
?>
I didn't realize the need for the 'cmd /C' until I saw the stderr response 'dir:
not found'.
----
Manual Page -- http://www.php.net/manual/en/function.ssh2-exec.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+56564
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56564&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56564&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56564&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56564&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56564&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56564&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+56564&report=yes
Search -- http://master.php.net/manage/user-notes.php