0

I have been trying rather unsuccesfully to open several terminals (though one would be enough to start with) from say an ipython terminal that executes my main python script. I would like this main python script to open as many cmd terminals as needed and execute a specific python script on each of them. I need the terminal windows to remain open when the script finishes.

I can manage to start one terminal using the command:

import os
os.startfile('cmd')

but I don't know how to pass arguments to it, like:

/K python myscript.py 

Does anyone have any ideas on how this could be done?

Cheers H.H.

2 Answers 2

0

Use subprocess module. Se more info at. Google>>python subprocess

Sign up to request clarification or add additional context in comments.

1 Comment

I had a look at that but couldn't figure out how to create new terminal windows. It seems it starts the terminal in the same parent window.
0

http://docs.python.org/2/library/subprocess.html

    import subprocess
    subprocess.check_output(["python", "c:\home\user\script.py"])

or

    subprocess.call(["python", "c:\home\user\script.py"])

1 Comment

Thanks but it does not create a new window, but just runs the code within the same window. How to change that command to achieve that?

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.