All,
I am using a python script (v2.0) to call a batch file.

1. The python script should wait until the batch file is finished. (So that rules out os.startfile, os.popen etc.)
2. For unknown reason, os.system does not work ...

So I am using os.spawnv(os.P_WAIT,BatchFile, BatchFile)
where Batchfile =r"E:\..... \*.bat"

Now the problem I have is ....
I WANT TO PASS 3 ARGUMENTS TO THE BATCH FILE.
Can somebody help me? (PS.Urgent)

Advance thanks...


PS. Using os.putenv("VARNAME", value) in python and then using
%VARNAME% in batch file is not good enough... :( as I have multiple python scripts calling a batch file each simultaneously - and each have 3 variables (same varname, but different values) to pass.

Recommended Answers

All 2 Replies

Run an external program from within Python code with
subprocess.call(["program-name", "arg1", "arg2"])
rather than os.system("program-name arg1 arg2"),
since os.system() does not allow the Python program
to run in the background, whereas subprocess does.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.