0

In the php code exec('python file.py 1 2',$result);

the $result give me the code inside the file.py but I need the output from print. Suppose file.py do an addition job.

var_dump($result) -> import sys print int(sys.argv[1]) + int(sys.argv[2])

instead of var_dump($result) -> 3

Also got this problem when using exec('php file.php 1 2',$result).

safe_mode is already turn off

2 Answers 2

0

You should tell more about the the platform you are trying to execute the script on.

Back to the question, I'd guess that you didn't properly point to the path of the Python interpreter - try something like this: exec('C:\\python27\\python.exe file.py 1 2',$output);

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

1 Comment

The platform of my system is Linux SUSE s390x python --version -> Python 2.6 For, the compile language like exec('java or gcc or g++ ....',$output) is give the output from println printf
0

$value = exec('python /var/www/neptenderapp/upload/hough.py ' . $_FILES["file"]["name"]); The last output of your python script will be sent as value to this variable $value. While executing the python script, you could give full path to the python script in the php exec command and do a os.chdir('/var/www/upload') at the beginning of your python script as well. If you have any problems, please do visit once, this link where I have documented how I solved my problem similar to yours. If further problem arises, do keep asking for more answers in here.

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.