this is my first post so, please Please be lenient :)
With reference at the subject, before writing I have really done a thorough research on stack overflow and the answer closest I could find was Passing value from PHP script to Python script.
In my test I've this situation: prova.php file:
<?php
$item1 = 3;
$item2 = 4;
$tmp = exec("python ../cgi-bin/test.py $item1 $item2");
echo $tmp; // invia la richiesta a Python
?>
Then in the Python test.py file I wrote:
#!/usr/local/bin/python
import sys
print sys.argv[1] , sys.argv[2]
All this works fine and the page prova.php shows the values โโof the variables, ie 3 and 4
What I can't understand is how to proceed in test.py to make e.g. product sys.argv[1] * sys.argv[2]
and return it to PHP.
All attempts I made show "prova.php" as a blank page.
Thanks in advance for your attention.
==================================================================== WOW, Dear Georg, Matt, Andrew and Jarek, Thank you so much for your valuable advice! In a few minutes you have solved a problem that I was analyzing from hours (as you may have guessed I'm a beginner).
Now everything works perfectly!
If possible, I would like to know one more thing: is there a way that when python runs the line "print ..." (to return the result in $output), the value is not displayed on the page prova.php, but only stored in $output?