2

I want to send string from php script to python:

php script:

$row = "successful";
        
$c= escapeshellcmd('python C:\wamp64\www\project\GUI.py ' .$row);
echo $c;

python:

url1 = 'http://localhost:9090/project/file.php'
    x2 = urllib.request.urlopen(url1)
    data = x2.read()
    d = str(data)

    encode = x2.info().get_content_charset('utf8')
    print(d)

i am getting nothing in python script kindly help thank you

sam
  • 309
  • 2
  • 9
  • python: some of the code provided is not enough. What does len (sys.argv) give in Python? – kubarik Apr 12 '21 at 08:20
  • 1
    PHP: Did you cehck what [escapeshellcmd()](https://www.php.net/manual/en/function.escapeshellcmd.php) actually does? It's for escaping data. It doesn't actually execute the command. There are plenty of examples in the manual. You can also read [this post](https://stackoverflow.com/questions/732832/php-exec-vs-system-vs-passthru) with some info what function to use in what case. – M. Eriksson Apr 12 '21 at 08:30
  • 1
    @kubarik when i use sys.argv[1] in python script it gives me out of index error – sam Apr 12 '21 at 10:28
  • @kubarik 'What does `len (sys.argv)` give in Python?' it is giving 1 as output – sam May 19 '21 at 04:48

0 Answers0