Reputation:
I am exploring the use of Python to perform tasks in CMD, using os.system()
However, I found a few issues that prevents you from executing more than one command through python, along with the problem that as soon as the task is completed, the window closes.
import os
os.system('ipconfig', 'netstat')
The error that arose from this was that system() takes at most 1 argument (2 given)
import os
os.system('ipconfig')
os.system('netstat')
The problem that arose from this idea was that as soon as ipconfig had completed, I was ejected from the window and netstat began in a new terminal. After netstat had finished, before I could read the data recieved I was ejected from this terminal too.
How can I run two commands that follow one after the other, but in the same window? (I'd be able to scroll up and view the previous command and it's data.) And how can I prevent CMD from ejecting me from the window?
Upvotes: 1
Views: 1093
Reputation:
Use os.system('command & pause')
'&' Allows you to string multiple commands within the same window which will execute one after the other.
'Pause' Asks for user input to exit from the terminal.
Upvotes: 1