By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,929 Members | 1,597 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,929 IT Pros & Developers. It's quick & easy.

Proc_open() a python script

P: 2
hi!
i want to execute a python script from php through proc_open() function of php.. i read a fine tutorial at
http://stackoverflow.com/questions/1...strings-in-php

when i made following py script.

print 'enter value'
input = raw_input()
print input

and linked it with php through following php code

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $descriptorspec = array(
  4. 0 => array("pipe","r"),
  5. 1 => array("pipe","w"),
  6. 2 => array("file","./error.log","a")
  7. ) ;
  8.  
  9. $process = proc_open('test.py', $descriptorspec, $pipes);
  10.  
  11. print fgets($pipes[1]) ;
  12. $p = 126;
  13. fwrite($pipes[0], $P);
  14. print fgets($pipes[1]) ;
  15.  
  16. fclose($pipes[1]);
  17. fclose($pipes[0]);
  18. proc_close($process);
  19.  
  20. ?>
it runs fine till first statement 'enter value'.. but at the next line raw_input() produces EOF error. im unable to send a value from php to python. i wonder what to do..
Feb 10 '09 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.