I want to create a program by python, when the program is run, it show its own command line interface. The user can input a command into the interface, and the program will handle that command. Is there any way to do that in both Windows and Linux environment?
Asked
Active
Viewed 312 times
1 Answers
2
this should work for both linux and windows:
from subprocess import call
while True:
print call(raw_input("command: "), shell = True)

Liam
- 6,009
- 4
- 39
- 53
-
Thanks for your answer, but as I know raw_input() function does not work in windows – Waveter May 11 '16 at 10:07
-
2@Waveter it works, but only for python 2.x, if you have python 3.x you should use `str(input("command: "))` – Liam May 11 '16 at 10:09