I have a php file that pass file name as string variable to python. And once the python receive the string variable it will open the file based on the string variable.
python file
python file
#!C:\Python\Python39\python.exe print ('Content-type: text/html\n\n') import sys print(sys.argv) filename = sys.argv[1] print(filename) with open(filename+'.py', 'r') as inFile: print(inFile.read())php file
$filename = "stringfile"; $command = "python receivephpvariable.py \"$filename\""; echo $command ; echo shell_exec($command);but i got the error :
Error:['c:\\xampp\\htdocs\\project_real\\receivephpvariable.py']
Traceback (most recent call last):
File "c:\xampp\htdocs\project_real\receivephpvariable.py", line 5, in <module>
filename = sys.argv[1]
IndexError: list index out of range