4

I have a python script which do some processing over images and gives me text, the script is running fine in the console. Now i want to display the same text by using php in a browser.

When i use the below code, i get the proper values in php variables $f and $v when i exectute the code from console but when i execute the code from browser i don't get any value in php variables

   exec('python /var/www/abc/abc.py', $f, $v);
   echo $f;
   echo $retval;

In python script: I have something like this

  code...
  code...
  ......
  #in the end
  print text
  sys.stdout.flush() 

How can i get the print values in python script in my php variables??

1 Answer 1

4

Make sure $f is an array before calling exec(), then print_r($f) should do the trick

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

2 Comments

yeah its an array, and its always prints as blank
Thanks, that was what was wrong for me. Forgot to make an array before calling.

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.