The command needs to invoke the python interpreter, right now it is just a file name.
$id = escapeshellarg($_GET["id"]);
$command = "python addid.py --id $id";
$job = shell_exec($command);
Question
I have python file in /usr/local/bin
I can run it anywhere in server using addid.py --id [id]
And now I need to run it from php file: add.php?id=[id]
<?php
$id = $_GET["id"];
$command = "addid.py --id $id";
$job = shell_exec($command);
echo $job;
print '<hr/>';
print $command;
?>
Page loads faster, but python program actually works longer (~30 seconds). Also cannot see python program in htop
(task manager). It prints < hr > line and result of $command (string).
Also added export PATH=$PATH:/usr/local/bin
to /etc/sysconfig/httpd
What is wrong?
La solution
The command needs to invoke the python interpreter, right now it is just a file name.
$id = escapeshellarg($_GET["id"]);
$command = "python addid.py --id $id";
$job = shell_exec($command);