Fw: [PHP-WIN] Extension php_ssh2.dll: function ssh2_exec, stream returns only 65536 bytes
| From: | Edin Kadribasic | Date: | Tue, 14 Jun 2005 13:18:04 +0000 |
| Subject: | Fw: [PHP-WIN] Extension php_ssh2.dll: function ssh2_exec, stream returns only 65536 bytes | ||
| Groups: | php.pecl.dev | ||
| Request: | Send a blank email to pecl-dev+get-2471@lists.php.net to get a copy of this message | ||
Maybe pecl-dev is the righ place for this?
Edin
----- Original Message -----
From: <mmarsian@web.de>
To: <php-windows@lists.php.net>
Sent: Tuesday, June 14, 2005 3:10 PM
Subject: [PHP-WIN] Extension php_ssh2.dll: function ssh2_exec, stream
returns only 65536 bytes
Hi All,
i'm using the PHP Version 5.0.4 with Apache 2.0.54 on Windows XP SP2 and the
latest Extension Module php_ssh2.dll.
I'm making a ssh2 connection to a SuSE 9.1 linux box with sshd version
OpenSSH_3.8p1.
1. and most important:
if i use the ssh2_exec() function and read the returned stream, i get only
the first 65536 bytes of the commands output.
How can i change this?
2. and less important:
if I use the compression setting "zlib" in the server_to_server direction
the output is garbled. Am I doing something wrong or should I not use it?
Example code here:
<?php
function my_ssh_disconnect($reason, $message, $language) {
printf("Server disconnected with reason code [%d] and message: %s\n",
$reason, $message);
}
$methods = array(
'kex' => 'diffie-hellman-group1-sha1',
'client_to_server' => array(
'crypt' => 'aes256-cbc',
'comp' => 'none',
'mac' => 'hmac-sha1'),
'server_to_client' => array(
'crypt' => 'aes256-cbc',
'comp' => 'none',
'mac' => 'hmac-sha1'));
$callbacks = array('disconnect' => 'my_ssh_disconnect');
$ssh_host = "gate01";
$connection = ssh2_connect($ssh_host, 22, $methods, $callbacks);
if (!$connection) die('Connection failed');
echo "Connected with $ssh_host<br>\n";
$fingerprint = ssh2_fingerprint($connection,
SSH2_FINGERPRINT_MD5 | SSH2_FINGERPRINT_HEX);
echo "This host's Fingerprint is: $fingerprint\n<br>";
$user_name = "root";
if (ssh2_auth_pubkey_file($connection,
$user_name,'C:\ProxyMgR\Keys\testkey.pub',
'C:\ProxyMgR\Keys\testkey', 'password')) {
echo "Public Key Authentication Successful as user: $user_name<br>\n";
} else {
die('Public Key Authentication Failed');
}
$ssh_command = "cat /etc/squid/squid.conf"; //
<------------------ the file is longer than 65535 bytes
echo "Executing Command: $ssh_command<br>\n";
echo "<pre>";
$stream = ssh2_exec($connection, $ssh_command);
stream_set_blocking( $stream, true );
while ( $inhalt = fread( $stream, 8192 )) { //
<------------------- the loop only returns 65536 bytes
echo "$inhalt";
}
echo "</pre>";
?>
_________________________________________________________________________
Mit der Gruppen-SMS von WEB.DE FreeMail können Sie eine SMS an alle
Freunde gleichzeitig schicken: http://freemail.web.de/features/?mc=021179
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php