By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,156 Members | 1,071 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,156 IT Pros & Developers. It's quick & easy.

Php Secure Shell2 (ssh2) Unable to request command execution onremote host

P: n/a
I have simple script:
<?php
$connection = ssh2_connect("ip", 22);
ssh2_auth_password($connection,"login","test");


sleep(10);
ssh2_exec($connection,"show log\n");


?>
Error message:
Unable to request command execution on remote host in
/home/konstantyn/www/php/test/11.php5 on line 13

Help me please....
Greetings,
Konstantyn Varlamov
Jul 5 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Varlamov Konstantyn kirjoitti:
Help me please....
Greetings,
Konstantyn Varlamov
You've asked now repeatedly several times the same thing. I'm sure that
if someone knows the answer, he or she will answer you, but for now
you'll just need to cool down and wait for a while. It doesn't help at
all that you keep asking the same thing over and over. The question is
here now and the people will try to help you with your trouble. Just
wait. If you feel you need to add something to the original question,
reply in one of the threads you've started, but please don't start any
new threads anymore. Patience is a virtue.

--
Ra*********@gmail.com

"Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze
Jul 5 '07 #2

P: n/a
On 2007-07-05, Varlamov Konstantyn <ko**********@gmail.comwrote:
I have simple script:
<?php
$connection = ssh2_connect("ip", 22);
Here, you can check $connection, as in:
if (! $connection) {
die("Connection failed.");
}
ssh2_auth_password($connection,"login","test");
Here, you can check if the auth succeeded, as in:
if (! ssh2_auth_password($connection,"login","test")) {
die("Auth failed.");
}
sleep(10);
ssh2_exec($connection,"show log\n");
Is "show log" a valid command? I think this
is what may be messing you up. Try something simple
like "/bin/ls", also you want to set a variable
as in:
$stream = ssh_2exec($connection, ...);
and then I think you might trying examining $stream:
stream_set_blocking($stream, true);
$output = stream_get_contents($stream);
?>
Error message:
Unable to request command execution on remote host in
/home/konstantyn/www/php/test/11.php5 on line 13

Help me please....
Greetings,
Konstantyn Varlamov
Hope this helps a little,

Charles

Jul 5 '07 #3

P: n/a
Rami Elomaa пишет:
Varlamov Konstantyn kirjoitti:
>Help me please....
Greetings,
Konstantyn Varlamov

You've asked now repeatedly several times the same thing. I'm sure that
if someone knows the answer, he or she will answer you, but for now
you'll just need to cool down and wait for a while. It doesn't help at
all that you keep asking the same thing over and over. The question is
here now and the people will try to help you with your trouble. Just
wait. If you feel you need to add something to the original question,
reply in one of the threads you've started, but please don't start any
new threads anymore. Patience is a virtue.
I am undrestend)I am waiting)
Jul 5 '07 #4

P: n/a
<?php
$connection = ssh2_connect("login", 22);

if (! $connection) {
die("Connection failed.");
}
else echo "connect OK";

if (! ssh2_auth_password($connection,"user","test")) {
die("Auth failed.");
}
else echo "login OK";
sleep(10);
$stream=ssh2_exec($connection,"show log\n");
stream_set_blocking($stream, true);
$output = stream_get_contents($stream);

?>

connect OKlogin OK
Warning: ssh2_exec(): Unable to request command execution on remote host
in /home/konstantyn/www/php/test.php5 on line 22

Warning: stream_set_blocking(): supplied argument is not a valid stream
resource in /home/konstantyn/www/php/test.php5 on line 25

Warning: stream_get_contents() expects parameter 1 to be resource,
boolean given in /home/konstantyn/www/php/test.php5 on line 26

Re:

The remote server is not a computer, it`s Dlink DES-3526 Ethernet Switch.
Command "show log" is valid comand for him.
Connection and login works but command executing triggers error.
Jul 5 '07 #5

P: n/a
Varlamov wrote:
$stream=ssh2_exec($connection,"show log\n");
Maybe newline is not wanted?

Jul 5 '07 #6

P: n/a
Tis is not work to
<?php
$connection = ssh2_connect("login", 22);

if (! $connection) {
die("Connection failed.");
}
else echo "connect OK";

if (! ssh2_auth_password($connection,"user","test")) {
die("Auth failed.");
}
else echo "login OK";
sleep(10);
$stream=ssh2_exec($connection,"show log");
stream_set_blocking($stream, true);
$output = stream_get_contents($stream);

?>

connect OKlogin OK
Warning: ssh2_exec(): Unable to request command execution on remote host
in /home/konstantyn/www/php/test.php5 on line 22

Warning: stream_set_blocking(): supplied argument is not a valid stream
resource in /home/konstantyn/www/php/test.php5 on line 25

Warning: stream_get_contents() expects parameter 1 to be resource,
boolean given in /home/konstantyn/www/php/test.php5 on line 26
Jul 6 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.