5

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

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 in the cmd window and next it closes very quickly not letting me see what was the error. How can I prevent this cmd window to close?

0x90
41.4k41 gold badges179 silver badges263 bronze badges
asked May 15, 2013 at 17:59
1
  • Normally, os.system won't actually open a new cmd window for the other process. If you get one from abaqus, that's because of something Abaqus does itself. Commented Sep 16, 2023 at 4:42

4 Answers 4

7

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

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

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

answered May 15, 2013 at 18:02
Sign up to request clarification or add additional context in comments.

Comments

2

just use the commande "pause" it will ask you to press a key to continue.

answered May 15, 2013 at 18:04

Comments

1
os.chdir('C:/Abaqus_JOBS' + JobDir)
os.system('abaqus job=' + JobName + '-3_run_rel2 user=FalseworkNmm41s interactive')
raw_input("Press Enter...")
answered May 15, 2013 at 18:04

Comments

1

All of these work. I prefer the input("press enter"), but at fist I imported time, and added time.sleep(500), which would give me 500 secs to see what's going on. You can put in even more seconds.

answered May 15, 2013 at 18:08

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.