I
I
iamserge2017-07-31 00:51:40
PHP
iamserge, 2017-07-31 00:51:40

Using SSH in php - how to send commands correctly?

$connection = ssh2_connect($srvip, 22);
if(ssh2_auth_password($connection, $slogin, $passwd)) {
  $stream = ssh2_exec($connection, "wget -P /var/www/КИРИЛЛИЦА.РУ https://zip.org/zip.zip; ");
  stream_set_blocking($stream, true);
  $stream_out = ssh2_fetch_stream($stream, SSH2_STREAM_STDIO);
  $rl = stream_get_contents($stream_out);
}

This is such a simple code, but I have two problems:
1. I can't get the result of the execution into the $rl variable normally - just because of this I don't know what the error is. So the question is how to get it?
2. It seems that everything is because of the Cyrillic alphabet in the folder name and, accordingly, in the command text, the parameter begins to contain it. I ask you to take this into account as well and I want to deal with this too .....

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2017-07-31
@shambler81

php.net/function.exec

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question