0

I want to run/call an existing bat file in Python Spyder.

I tried the following two codes. Both start the command window but then it quickly quits/exits. I would highly appreciate your help.

Option 1)

Import os


os.system("path....\\xxx.bat")

Option 2)

Import subprocess


subprocess.call ("path....\\xxx.bat")
Subhrajyoti Das
  • 2,497
  • 3
  • 19
  • 31
zafiros
  • 3
  • 3
  • please post real command you're using... and use `check_call` to get exception on failure. – Jean-François Fabre Jul 25 '19 at 09:28
  • 1
    Possible duplicate of [Calling an external command in Python](https://stackoverflow.com/questions/89228/calling-an-external-command-in-python) – Tomerikoo Jul 25 '19 at 10:23
  • still not the real command... try to call from a console, and check the errors it prints... – Jean-François Fabre Jul 25 '19 at 11:25
  • thanks your your answers. Unfortunately, I cannot share the real command here. But I can tell you that the command X calls another command y and provides y some variables. – zafiros Jul 26 '19 at 12:55

0 Answers0