I know there are tons of questions on this topic but none seem to provide an answer that solves all my requirements.
My requirements:
- Start another application (should support all kinds of applications: long running processes taking user input, simple applications ending quickly or applications that take a long time)
- Should also be able to start applications that end immediately (ex: 'git status')
- It needs to start in a new console window
- The console window should remain active even after command completion to see the application output.
- It needs to be cross platform (Windows and Linux)
I want to use subprocess module. I already tried using the option CREATE_NEW_CONSOLE
subprocess.Popen(("git", "status"), close_fds=True, creationflags=subprocess.CREATE_NEW_CONSOLE | subprocess.STARTF_USESHOWWINDOW, shell=True)
but:
- It does not really work. I see no window starting, or may be it is starting but exiting too fast after command execution.
- this only works for Windows. Was wondering if there is a way to do this on all platforms consistently ?