Open cmd window

I have python code in a program that opens a cmd window and runs another program there. The code looks like this:

os.chdir('C:/Abaqus_JOBS' + JobDir) os.system('abaqus job=' + JobName + '-3_run_rel2 user=FalseworkNmm41s interactive') 

Now everything works, but I get an error message in the cmd window, and then it closes very quickly, not allowing me to see what was the error. How can I prevent this cmd window from closing?

+4
source share
4 answers

Add + " & timeout 15" or + " & pause" to the string passed to os.system :

 os.chdir('C:/Abaqus_JOBS' + JobDir) os.system('abaqus job=' + JobName + '-3_run_rel2 user=FalseworkNmm41s interactive' + " & timeout 15") 

consider popen instead ( Difference between subprocess.Popen and os.system ).

+5
source

just use the pause command, it will ask you to press a key to continue.

+2
source
 os.chdir('C:/Abaqus_JOBS' + JobDir) os.system('abaqus job=' + JobName + '-3_run_rel2 user=FalseworkNmm41s interactive') raw_input("Press Enter...") 
+1
source

All these work. I prefer input ("press enter"), but I imported time into the fist and added time.sleep (500), which would give me 500 seconds to see what happens. You can add a few more seconds.

+1
source

Source: https://habr.com/ru/post/1481004/


All Articles