1

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?

Waveter
  • 890
  • 10
  • 22

1 Answers1

2

this should work for both linux and windows:

from subprocess import call

while True:
    print call(raw_input("command: "), shell = True)

output

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