Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
subprocess.Popen
#1
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)
Reply
#2
Use shell=False when the first argument is a list.
Reply
#3
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?
Reply
#4
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Information subprocess.Popen() suddenly giving me grief? davecotter 3 626 Dec-13-2023, 10:49 PM
Last Post: davecotter
  Use subprocess.Popen and time.sleep chucky831 2 1,954 Aug-11-2022, 07:53 PM
Last Post: carecavoador
  Subprocess.Popen() not working when reading file path from csv file herwin 13 15,112 May-07-2021, 03:26 PM
Last Post: herwin
  Did subprocess.Popen() causes main routine to pause stdout? liudr 4 3,656 May-04-2021, 08:58 PM
Last Post: liudr
  disable subprocess.popen prompt echo paul18fr 1 2,020 Feb-04-2021, 02:50 AM
Last Post: Larz60+
  how to pass the interactive string to Popen subprocess maiya 1 1,886 Sep-18-2020, 09:36 PM
Last Post: Larz60+
  How to get program output from subprocess.Popen? glestwid 1 2,378 Aug-19-2020, 05:44 AM
Last Post: buran
  subprocess.Popen() and encodings voltron 0 5,753 Feb-20-2020, 04:57 PM
Last Post: voltron
  Mock call to subprocess.Popen failing with StopIteration tharpa 7 5,940 Nov-08-2019, 05:00 PM
Last Post: Gribouillis
  no coding= option fo subprocess.Popen() Skaperen 5 5,732 Jun-21-2019, 10:24 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020