Python script call from php does not execute as expected
I created a python script to get a directory tree. Now I am trying to call this script from php using system ().
My Python script:
import os
from sys import argv
script, start = argv
def list_files(startpath):
directory = []
for root, dirs, files in os.walk(startpath, topdown=True):
for named in dirs:
directory.append(os.path.join(root, named))
for namef in files:
directory.append(os.path.join(root, namef))
return directory
dir = list_files(start)
My PHP command:
$var = system('C:\\Python27\\python.exe generate -tree.py F:\\IET', $retval);
echo $var;
echo $retval;
The result I get in the browser is the number "2" and when I did it the day before exiting as the number "1".
I'm new to PHP so couldn't figure out what I was doing wrong here. Any guidance would be appreciated!
+3
source to share
No one has answered this question yet
Check out similar questions: