-1

I want to send data with php and get with python. But shell_exec cannot send parameter. I cannot understand where is the problem. this does not fix my error

this is my php file

    <?php
    if(isset($_POST["username"])){
        $nick = $_POST["username"];
    echo $nick;//prints ozan to webpage
  $res = shell_exec("C:\Python27\python.exe C:\wamp\www\MLWebsite\website\new.py '".$nick."'");
        echo $res;
    }
    ?>

new.py

#!c:/Python27/python.exe
print("Content-Type: text/html")
print("""
  <TITLE></TITLE>
  <H1></H1>
"""
)

import pymysql.cursors
import sys
import json
import urllib2, urllib
import requests

x = sys.argv[1]
print x

Error

Content-Type: text/html

Traceback (most recent call last): File "C:\wamp\www\MLWebsite\website\new.py", line 15, in x = sys.argv1 IndexError: list index out of range

Please help me to solve this problem

ozan
  • 33
  • 1
  • 9

1 Answers1

0

This should do it

$res = shell_exec('C:\Python27\python.exe C:\wamp\www\MLWebsite\website\new.py ' . $nick);
Alam
  • 403
  • 5
  • 14