Proc_open() a python script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • YasirHussain
    New Member
    • Feb 2009
    • 2

    Proc_open() a python script

    hi!
    i want to execute a python script from php through proc_open() function of php.. i read a fine tutorial at
    I have a PHP application which needs to output a python script, more specifically a bunch of variable assignment statements, eg. subject_prefix = 'This String From User Input' msg_footer = """This...


    when i made following py script.

    Code:
    print 'enter value'
    input = raw_input()
    print input
    and linked it with php through following php code

    Code:
    <?php
    
    $descriptorspec = array(
    0 => array("pipe","r"),
    1 => array("pipe","w"),
    2 => array("file","./error.log","a")
    ) ;
    
    $process = proc_open('test.py', $descriptorspec, $pipes);
    
    print fgets($pipes[1]) ;
    $p = 126;
    fwrite($pipes[0], $P);
    print fgets($pipes[1]) ;
    
    fclose($pipes[1]);
    fclose($pipes[0]);
    proc_close($process);
    
    ?>
    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
    Last edited by bvdet; Feb 10 '09, 05:03 PM. Reason: added code tags
  • ogiebjl
    New Member
    • Feb 2010
    • 1

    #2
    PHP variables are case sensitive, $p is not the same as $P.

    Comment

    Working...