I am trying to pass the value of a variable from php to a python script.
php:
<?php
$item = array('warren');
$command = escapeshellcmd('hello.py $item');
$output = shell_exec($command);
echo $output;
?>
python:
#!/usr/bin/env python
import sys
input = sys.argv[1]
print input
This results in $item displayed. I've tried all manner of different quotation marks, but still can't get the actual value (warren) to be passed. How do I get the value stored in $item to get passed, not the literal?
I've also tried How to pass variable from PHP to Python?
Php:
<?php
$item = array('warren');
$output = shell_exec('hello.py' . $item);
echo $output;
?>
But this gives me error:
Notice: Array to string conversion in C:\wamp64\www\crud\clientdetails.php on line 613
$output = shell_exec('hello.py' . $item);$output = shell_exec('hello.py ' . $item[0])