By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,908 Members | 1,945 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,908 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.

Expand|Select|Wrap|Line Numbers
  1. print 'enter value'
  2. input = raw_input()
  3. 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.. i came in python thread because the problem here is in python script
Feb 10 '09 #1
Share this Question
Share on Google+
1 Reply


P: 1
PHP variables are case sensitive, $p is not the same as $P.
Feb 26 '10 #2

Post your reply

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