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

  • SEARCH
  • Home
  • 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 3229400
In Process

The Archive Base Latest Questions

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

I’ve been trying to solve this issue for sometime now with no luck. The

  • 0

I’ve been trying to solve this issue for sometime now with no luck. The crust of the situation is that I’m using a bash script to send parameters to a a python script:

Example:

foo.sh calls bar.py….the call looks like: bar.py $var1 $var2 … $varn

The python script then prints all the arguments using the sys.argv array. The python script works correctly from the command line, but when called from with the bash script (i.e foo.sh), I get no output from bar.py.

Also, I started foo.sh with the “#!/bin/bash -x” option and watched the output as well.

TO summarize:

  • Two scripts, foo.sh and bar.py
  • foo.sh calls bar.py, passing variables of foo.sh as arguments to bar.py
  • bar.py prints the arguments it sees using sys.argv
  • bar.py works when run from its own terminal, doesn’t work when called from foo.sh

Any help would be awesome!!!!

Thanks!

Edit: Hi all, thanks for the replies, the complete code is pretty long…but… the contents of the two scripts could be summed

foo.sh ____

#!/bin/bash
declare -a list1;  
declare -a list2;  

list1=("foo" "bar" "please");  
list2=("foo" "bar" "please" "help");  

declare -a joined;  

joined=( $(bar.py "${list1[@]}" "${list2[@]}" ) );

bar.py ____

#!/bin/python
import sys  

for arg in sys.argv:  
    print arg  

As I assume all the indents in the python are correct (not sure how StackOverflow does this yet 🙂 ). These two represent the core of the issue i’m having. As stated, bar.py prints arguments correctly, when it it not called from foo.sh.

PS: I did mean to say “crust”

  • 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-17T16:48:23+00:00Added an answer on May 17, 2026 at 4:48 pm

    Edit, since code has been posted

    Your code is doing the correct thing – except that the output from your bar.py script is being captured into the array joined. Since it looks like you’re not printing out the contents of joined, you never see any output.

    Here’s a demonstration:

    File pybash.sh

    #!/bin/bash
    
    declare -a list1
    declare -a list2
    
    list1=("Hello" "there" "honey")
    list2=("More" "strings" "here")
    
    declare -a joined
    
    joined=($(./pytest.py ${list1[@]} ${list2[@]}))
    echo ${joined[@]}
    

    File pytest.py

    #!/usr/bin/python
    
    import sys
    
    for i in sys.argv:
        print "hi"
    

    This will print out a bunch of ‘hi’ strings if you run the bash script.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm looking for suggestions for debugging... If you view this site in Firefox or
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.