***************I have two script*************************
File name : abcd.py
def fun() :
x = 1
return x
z = fun()
print z
File name xyz.lua
os.execute('start cmd /c C:/Python34/python.exe "C:/Folder/abcd.py"')
I am not getting result. Plesae help me on this, how can i execute a python script from lua. Here i want to run abcd.py script from xyz.lua
I am working in windows environment.
os.executeprovides return/status code only.os.execute('start cmd /k C:/Python34/python.exe "C:/Folder/abcd.py"')startworks, that meansos.executealready uses the CMD shell. You don't need another instance. Usingstartwill cause python.exe to allocate a new console. Without/w, the shell won't wait for python.exe to exit. If you don't need a new console, run'"C:\\Python34\\python.exe" "C:/Folder/abcd.py"'. If you need a new console plus the exit code, make it wait via'start "" /w "C:\\Python34\\python.exe" "C:/Folder/abcd.py"'. CMD needs backslashes for the python.exe path. Python accepts slashes for the "abcd.py" path.os.executeis naive about CMD'sbehavior, you may need to wrap the entire command in double quotes, in particular if it starts with a quoted path, because CMD will strip the first and last quotes. For example, run'""C:\\Python34\\python.exe" "C:/Folder/abcd.py""'.