0

I want a way to pass input into a python script from PHP. I am using the following command but can't seem to figure out a way to pass a value to the script

$command = escapeshellcmd('/usr/custom/test.py');
$output = shell_exec($command);
1
  • you could pass it as arguments to the script ? Like /usr/custom/test.py <arg1> <arg2> ...> Commented Feb 14, 2019 at 14:00

1 Answer 1

1

for example you have a simple input like this :

<input type="text" name="name"><br>

To pass it you can simply do like this:

<?php system("python mycode.py ".$_POST["name"]); ?>

you can also use exec() and passthru()

system("python mycode.py <arg1> <arg2>");

//or

exec("python mycode.py <arg1> <arg2>");

//or

passthru("python mycode.py <arg1> <arg2>");

have a good time !

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.