Python Forum

Full Version: subprocess.Popen
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I was wondering if any of you know of the way to pass multiple parameters into subprocess.Popen.
In the code below, I pass str(my_var). Is there a way to do something like str(my_var_1), str(my_var_2)?
Thank you so much! This forum is awesome!

item = subprocess.Popen(["batch_test_python_petrel_saving_Nexus.bat", str(my_var)] , 
                         shell=True, stdout=subprocess.PIPE)
Use shell=False when the first argument is a list.
Hi, thank you for your reply. I then use batch file and assign my variables which was not a problem with a single variable being passed in. Inside my batch, I did it like this:
@echo off
set arg1=%1
set /a vari=%arg1%
However, now I am not certain how to do what is above as I have multiple variables.
Any suggestions?
If I understand your question well, you want to know how to handle command line parameters in a batch script. I can't answer this because it is not a question about python. Why don't you write a python script instead of a batch script? Python can handle command line parameters very easily with the argparse module.