0

I found a way to get only one variable, And I need 18

I am currently using the code

echo shell_exec("C:/Python/python.exe C:/wamp64/www/site/test.py 2>&1");

The code Works great but how do I send variables to python?

3
  • If I Google your question I get this answer: stackoverflow.com/questions/12197815/… What did you try so far, I think this question is asked already many times Commented Jul 29, 2020 at 21:10
  • I tried but it does not work for me with two variables Commented Jul 29, 2020 at 21:13
  • why dont you insert 1 variabe as json string and decode it in python Commented Jul 29, 2020 at 21:14

1 Answer 1

1

You just pass them as command line arguments:

exec ( "C:/Python/python.exe C:/wamp64/www/site/test.py $var1 $var2 $var3" );

Then in your Python script you can read them like this:

import sys

print sys.argv[1] # first parameter
print sys.argv[2] # second parameter
print sys.argv[3] # third parameter
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.