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 9237549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:33:34+00:00 2026-06-18T07:33:34+00:00

I am trying to pass several parameters from a python script to a bash

  • 0

I am trying to pass several parameters from a python script to a bash script in the following way:

input_string = pathToScript + " " + input1 + " " + input2 + " " + input3 + " " + input4 + " " + \
input5 + " " + input6 + " "  + input7 + " " + input8 + " "  + input9 + " "  + input10

args =  shlex.split(input_string)

p = subprocess.Popen(args)

where all the inputX are strings. Each of these arguments shall be passed to the script, whose path is stored in the variable pathToScript. I now want to be able to catch these parameters in the bash script like I usually do:

#No input check yet...
history_file = "$1"
folder_history_file = "$2"
folder_bml_files = "$3"
separate_temperature = "$4"
separate_temperature_col_index = "$5"
separate_sight = "$6"
separate_sight_col_index = "$7"
separate_CO = "$8"
separate_CO_col_index = "$9"
separate_radiation = "$10"

This causes errors like line 61: separate_CO_col_index: command not found for all these lines and the errors do not appear in the same way the lines are ordered. In other words such error on line 61 is sometimes caught before the one on line 60, it seems from the output in Eclipse (I use PyDev in Eclipse).

Is it not possible to run the bash script like this? I have tried following the method in ch. 17.1.1.1 here, but I may not have understood it correctly: python docs

  • 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-06-18T07:33:35+00:00Added an answer on June 18, 2026 at 7:33 am

    The errors in bash appear because you put spaces around the =. You should use

    history_file="$1"
    

    instead of

    history_file = "$1"
    

    When you put spaces there, Bash thinks the line is a command invocation and tries to run history_file as a command.


    In your Python script, you can simply use:

    args = [pathToScript, input1, input2, ....]
    

    instead of what you have. This is simpler, and will work correctly if the arguments contain spaces, which your current code will fail on. There’s no point in building the input_string string only to split it back in the following line.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to pass several search parameters to an LINQ expression to retrieve
I'm trying to pass several distinct pieces of information to a kernel-mode driver from
I'm trying to pass parameters from HTML-land to Flex-3 Flash-land, and can't seem to
im trying to pass two parameters to a function, i being an int value
I'm trying to pass a template to my view. I have several different templates
I have the following code, and I am trying to pass datetime as a
I am trying to pass several values through an IMultiValueConverter to a command (as
I'm trying to pass through several functions a string with a path but the
I'm trying to pass a parameter between a JSF page to another, from a
I am trying to build an array from a list of URL parameters to

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.