exec() command not working in WordPress

Does anyone know of this issue? I am using exec() command to execute my python script from wordpress(WordPress 4.4.2 i),But Its not returning anything,I am using windows 7 /wamp. when I tried to run the same script from /wamp/www its working fine.
here is my php script:

exec("C:Python27python.exe D:wampwwwpython_script.py ",$out);
echo '<pre>';print_r($out);

In python I am just trying to print 'Hello World';

Read More

Any Idea?

Related posts

1 comment

  1. You’re using "-quoted strings, so C:Python27python.exe D:wampwwwpython_script.py is actually parsed as C:Python27python.exe D:wampwwwptyhon_script.py – the P, p, w etc are NOT string metacharacters, so the escape is simply lost in PHP, and never reaches the shell you’re executing.

    You need

    exec("C:\Python27\python.exe D:\wamp\www\python_script.py ",$out);
    

    instead. Note the doubled \.

    And note that this has nothing to do with WordPress. This is a PHP “problem”.

Comments are closed.