1

Hi I am running shell_exec on my PHP Application, Here is the code,

$path = "C:/scripts/";
chdir($path);
$py_commonscript = 'python Common_Script.py';
$exec = shell_exec($py_commonscript);

echo "<pre>$exec</pre>";

This code doesn't give any result and does not generate a file. When I tried running manually on the command line it is working and was able to generate a file.

I tried to execute this one below and it was able to display some result.

$sample = shell_exec('ls -lart');
echo "<pre>$sample </pre>";

I am wondering why the command for $exec is not being triggered or run.

1 Answer 1

1

The most likely cause is that your PHP code isn't inheriting a %PATH containing python.exe. Try print getenv('PATH'); or just use the full path to python.exe in your command line.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.