Running python script from php under windows

It's good that this works with my Linux server, but I'm testing my website at home on my PC and trying to get php to execute my python script, and of course it is 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 on my windows test server. How to do it for windows? Oh, and it also works when run directly from the command line in windows

EDIT:

THIS DECISION, as you can read in response.

$cmd = "$python $pyscript $filePath";
exec("$cmd", $output);

works like a charm. Single ticks have been changed to double.

+5
source share
1 answer

It seems strange to me that filePath from C:\\wamp\\....will work on a Linux machine. Anyway, have you tried NOT to avoid slashes?

, . , , , , , , , , , , , .

, , . http://www.php.net/manual/en/ref.exec.php

, , MOST, , backtick, system

- .

$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'

$cmd = "$python $pyscript $filePath";
echo $cmd;
`$cmd`


$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'

$cmd = "$python $pyscript $filePath";
echo $cmd;
`$cmd` 

: AHHH! , ", , . . , , , , ​​.

+6

All Articles