I
I
Igor Tkachenko2015-07-17 17:22:06
PHP
Igor Tkachenko, 2015-07-17 17:22:06

How to pass parameters to shell_exec php?

Interested in the question, how to pass parameters through shell_exec? For example:

shell_exec('php /var/www/html/script.php test test2');

And then work with them in the script.php file.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lesha Kiselev, 2015-07-17
@foozzi

$arg1 = escapeshellarg('test');
$arg2 = escapeshellarg('test2');

shell_exec('php /var/www/html/script.php "' . $arg1 .'" "' . $arg1 .'"');

In script.php:
var_export($argv); // Содержит массив переданных аргументов

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question