Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6126929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:26:23+00:00 2026-05-23T16:26:23+00:00

I have a program that I run from the command line that takes two

  • 0

I have a program that I run from the command line that takes two file arguments like this:

$ my_program

I would like to write a python script that can be used to run iterations of this program using different file arguments. For example:

$ my_program <file_1> <file_4>
$ my_program <file_2> <file_4>
$ my_program <file_3> <file_4>
...

I am trying to use the subprocess module from within python to run iterations of this program. What I can’t seem to figure out is how I can iterate throguth different file arguments and then run each of these commands from the command line. Can anyone point me in the right direction or provide some example code that woudl explain how this could be done. Thanks in advance for the help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:26:24+00:00Added an answer on May 23, 2026 at 4:26 pm

    From what I gather, you want something like this:

    cmds = [path_to_program, arg1, arg2]
    subprocess.Popen(cmds)
    

    then if you want to iterate through many, something like:

    cmds = [('file1', 'file4'), ('file2', 'file4'), ('file3', 'file4')]
    for arg1, arg2 in cmds:
        subprocess.Popen([path_to_program, arg1, arg2])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that is run from the command line like this python
I have a program that I run from the command line that looks like
I have a program that I run through the command line and I wanted
I have a plain perl script that can be run from the command-line via
I have a simple C++ program that I can compile (g++ from command line)
I have a java program that I would like to be able to run
i have a command line executable program that accepts a configuration file as it's
This is my problem. I have a program that has to run in a
I have a python program/file that I want to run repeatedly and calculate the
I am trying to run a java program from command line. I tried following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.