1

***************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.

6
  • Does this answer your question? Lua os.execute return value Commented Jun 3, 2020 at 6:30
  • os.execute provides return/status code only. Commented Jun 3, 2020 at 6:32
  • Try os.execute('start cmd /k C:/Python34/python.exe "C:/Folder/abcd.py"') Commented Jun 3, 2020 at 11:44
  • 1
    If start works, that means os.execute already uses the CMD shell. You don't need another instance. Using start will 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. Commented Jun 3, 2020 at 14:38
  • 1
    If os.execute is 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""'. Commented Jun 3, 2020 at 14:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.