Okay this works with my linux server but I'm testing my web site at home on my PC and am trying to get php to execute my python script and of course the \ are WINDOWS only the path changes when Im on my linux machine.
$pyscript = 'C:\\wamp\\www\\testing\\scripts\\imageHandle.py';
$python = 'C:\\Python27\\python.exe';
$filePath = 'C:\\wamp\\www\\testing\\uploads\\thumbs\\10-05-2012-523.jpeg'
exec('$python $pyscript $filePath', $output, $return );
this works on my linux machine but not my windows testing server. How do I get this to run on windows? Oh and this also works when running directly from the command prompt in windows
EDIT:
This is the solution:
exec("$python $pyscript $filePath", $output);
I used single quotes instead of double quotes before, changing the single quotes to double quotes fixed the problem.
This is a very old thread, but still comes up among the first results in Google, so it is worth an update.
In 2020, Under Python 3.8
and Windows 10
the right solution is simply:
<?
$output = shell_exec('C:\path\to\pythonscript.py');
print ($output);
?>
Everything else will result in an error. Took me a good few hours to figure out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With