Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running a batch file with parameters in Python OR F#

I searched the site, but I didn't see anything quite matching what I was looking for. I created a stand-alone application that uses a web service I created. To run the client I use:

C:/scriptsdirecotry> "run-client.bat" param1 param2 param3 param4

How would I go about coding this in Python or F#. It seems like it should be pretty simple, but I haven't seen anything online that quite matches what I'm looking for.

like image 401
Ramy Avatar asked Nov 29 '22 19:11

Ramy


1 Answers

Python is similar.

import os
os.system("run-client.bat param1 param2")

If you need asynchronous behavior or redirected standard streams.

from subprocess import *
p = Popen(['run-client.bat', param1, param2], stdout=PIPE, stderr=PIPE)
output, errors = p.communicate()
p.wait() # wait for process to terminate
like image 50
gradbot Avatar answered Dec 05 '22 14:12

gradbot