Running an external program (executable file) with parameters in python

I am trying to automate a command line program.

The exe uses one argument. For instance:

ztac.exe <mode> (where safe , normal or debug mode options).

To start in debug mode, simply enter this at the command line:

C:\source>ztac debug

How to write a Python program to run this ztac.exe file when using different modes as input?

+4
source share
1 answer
 program = 'ztac.exe' arguments = ('safe', 'normal', 'debug') argument = raw_input('Enter your argument: ') if argument in arguments: subprocess.call([program, argument]) else: print('Illegal Argument') 
+2
source

Source: https://habr.com/ru/post/1337274/


All Articles