how python by php code -


i want pass multiple variable php python .and print variable values through python code .(python3.4,runnning in localhost) sample code:

<?php $v1 = "1"; $v2 = "2"; $v3 = "3"; exec ( "/cgi-bin/z1.py $v1 $v2 $v3" ); ?> 

python code:

#!c:/python34/python.exe -u import sys  import cgitb ,cgi  print("content-type: text/html;charset=utf-8") print() print (sys.argv[1])  print (sys.argv[2])  print (sys.argv[3]) 

but in output it's not printing variable values.please suggest how can sent values or did mistake while specifying path

couple of typos:

 exec("c:\python34\pyhton.exe d:\xampp\cgi-bin\z1.py $v1 $v2 $v3" )                      ↑↑         ↑↑↑ 

in double quotes hexescapes \xaa interpreted byte sequences.

  • user either single quotes.
  • or standard path specifiers:

     exec("python 'd:/xampp/cgi-bin/z1.py' $v1 $v2 $v3") 

don't forget escapeshellarg reliable argument passing.


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -