I am writing a simple application that uses information from a form, passes it through $ _POST to a PHP script that runs a python script and prints the results. The problem I ran into is that my python script is actually not working with passed arguments.
process3.php file:
<?php $start_word = $_POST['start']; $end_word = $_POST['end']; echo "Start word: ". $start_word . "<br />"; echo "End word: ". $end_word . "<br />"; echo "Results from wordgame.py..."; echo "</br>"; $output = passthru('python wordgame2.py $start_word $end_word'); echo $output; ?>
Output:
Start word: dog End word: cat Results from wordgame.py... Number of arguments: 1 arguments. Argument List: ['wordgame2.py']
At the top of my wordgame2.py, I have the following (for debugging purposes):
#!/usr/bin/env python import sys print 'Number of arguments:', len(sys.argv), 'arguments.' print 'Argument List:', str(sys.argv)
Why is the number of arguments passed is not 3? (Yes, my form submits data correctly.)
Any help is much appreciated!
Edit: I can add that it starts when I directly say this start and end word ... something like this:
$output = passthru('python wordgame2.py cat dog'); echo $output
Micah
source share