I
I
Ilya Trusov2016-01-19 14:55:05
PHP
Ilya Trusov, 2016-01-19 14:55:05

How to run bash script from php?

Hello. There was a situation that you need to run a bash script from php. Yes, not secure. This is driven by jalkit.
I do it like this:

$connection = ssh2_connect('ip', 29937);

          if (ssh2_auth_password($connection, 'user', 'pass')) {

          ssh2_exec($connection, 'bash /home/user/create_user ' + $name_user_server + ' ' + $pass_user_server);
} else {

}

The connection is established. But the script is not executed.
And yet, how to run a script from sudo through php?
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dima Kim, 2016-01-19
@jalpy

can use CGI?

S
Saboteur, 2016-01-19
@saboteur_kiev

And the full path to bash to register?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question