Passing Bash array to Python scriptBash Array does not store correctlyUnable to pass a bash variable as a...

Addressing an email

In how many ways can we partition a set into smaller subsets so the sum of the numbers in each subset is equal?

How to fix "webpack Dev Server Invalid Options" in Vuejs

Head-internal relative clauses

Good examples of "two is easy, three is hard" in computational sciences

Could a chemically propelled craft travel directly between Earth and Mars spaceports?

Should I twist DC power and ground wires from a power supply?

Does a windmilling propeller create more drag than a stopped propeller in an engine out scenario?

Failing students when it might cause them economic ruin

Why does string strummed with finger sound different from the one strummed with pick?

Why were early aviators' trousers flared at the thigh?

Why does snapping your fingers activate the Infinity Gauntlet?

How to choose the correct exposure for flower photography?

Does the Aboleth have expertise in history and perception?

How could Dwarves prevent sand from filling up their settlements

Was Tyrion always a poor strategist?

Can a problematic AL DM/organizer prevent me from running a separate AL-legal game at the same store?

Is my company merging branches wrong?

Novel where a cube cooled below absolute zero makes a hole in reality

How to plot a surface from a system of equations?

Gambler's Fallacy Dice

How do you cope with rejection?

Does science define life as "beginning at conception"?

Hotel booking: Why is Agoda much cheaper than booking.com?



Passing Bash array to Python script


Bash Array does not store correctlyUnable to pass a bash variable as a python argument in bashSetting Qualifiers for Bash ArrayWhy does this array related code print the index at the end of each line?Sum up a given slice of elements in an array (bash)Passing paths with spaces as argumentsbash script read array outside loopIssue with array length in bash scriptReferencing bash array variables from another arrayHow to create a shell dictionary from an output of a python script?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I am having problem in sending bash array problem_list to python script update_contest.py. Here is my code :



bash file :



echo $problems
declare -a problem_list
for i in $problems;
do
problem_list+=($i)
done
echo ${problem_list[@]}
python3 update_contest.py $id ${problem_list[@]}


python file:



id = (sys.argv)[1]
problem_list = (sys.argv)[2]
print(problem_list)


output in terminal :



A B C D E
A B C D E
A


As can be seen, only A is passed as argument in problem_list.
Thanks in Advance !!!










share|improve this question









New contributor



Pratik Kale is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


























    0















    I am having problem in sending bash array problem_list to python script update_contest.py. Here is my code :



    bash file :



    echo $problems
    declare -a problem_list
    for i in $problems;
    do
    problem_list+=($i)
    done
    echo ${problem_list[@]}
    python3 update_contest.py $id ${problem_list[@]}


    python file:



    id = (sys.argv)[1]
    problem_list = (sys.argv)[2]
    print(problem_list)


    output in terminal :



    A B C D E
    A B C D E
    A


    As can be seen, only A is passed as argument in problem_list.
    Thanks in Advance !!!










    share|improve this question









    New contributor



    Pratik Kale is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      0












      0








      0








      I am having problem in sending bash array problem_list to python script update_contest.py. Here is my code :



      bash file :



      echo $problems
      declare -a problem_list
      for i in $problems;
      do
      problem_list+=($i)
      done
      echo ${problem_list[@]}
      python3 update_contest.py $id ${problem_list[@]}


      python file:



      id = (sys.argv)[1]
      problem_list = (sys.argv)[2]
      print(problem_list)


      output in terminal :



      A B C D E
      A B C D E
      A


      As can be seen, only A is passed as argument in problem_list.
      Thanks in Advance !!!










      share|improve this question









      New contributor



      Pratik Kale is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I am having problem in sending bash array problem_list to python script update_contest.py. Here is my code :



      bash file :



      echo $problems
      declare -a problem_list
      for i in $problems;
      do
      problem_list+=($i)
      done
      echo ${problem_list[@]}
      python3 update_contest.py $id ${problem_list[@]}


      python file:



      id = (sys.argv)[1]
      problem_list = (sys.argv)[2]
      print(problem_list)


      output in terminal :



      A B C D E
      A B C D E
      A


      As can be seen, only A is passed as argument in problem_list.
      Thanks in Advance !!!







      bash python






      share|improve this question









      New contributor



      Pratik Kale is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share|improve this question









      New contributor



      Pratik Kale is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share|improve this question




      share|improve this question








      edited 13 mins ago







      Pratik Kale













      New contributor



      Pratik Kale is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      asked 20 mins ago









      Pratik KalePratik Kale

      11




      11




      New contributor



      Pratik Kale is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




      New contributor




      Pratik Kale is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          You are indexing the list of arguments with 2, so only returning its second element, which is the first argument.



          Replace this line problem_list = (sys.argv)[2] with problem_list = sys.argv[2,-1].



          https://docs.python.org/3/library/sys.html





          share








          New contributor



          aiyqmiz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.




















            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "106"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });






            Pratik Kale is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f519625%2fpassing-bash-array-to-python-script%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            You are indexing the list of arguments with 2, so only returning its second element, which is the first argument.



            Replace this line problem_list = (sys.argv)[2] with problem_list = sys.argv[2,-1].



            https://docs.python.org/3/library/sys.html





            share








            New contributor



            aiyqmiz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.
























              0














              You are indexing the list of arguments with 2, so only returning its second element, which is the first argument.



              Replace this line problem_list = (sys.argv)[2] with problem_list = sys.argv[2,-1].



              https://docs.python.org/3/library/sys.html





              share








              New contributor



              aiyqmiz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.






















                0












                0








                0







                You are indexing the list of arguments with 2, so only returning its second element, which is the first argument.



                Replace this line problem_list = (sys.argv)[2] with problem_list = sys.argv[2,-1].



                https://docs.python.org/3/library/sys.html





                share








                New contributor



                aiyqmiz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                You are indexing the list of arguments with 2, so only returning its second element, which is the first argument.



                Replace this line problem_list = (sys.argv)[2] with problem_list = sys.argv[2,-1].



                https://docs.python.org/3/library/sys.html






                share








                New contributor



                aiyqmiz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.







                share


                share






                New contributor



                aiyqmiz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.








                answered 2 mins ago









                aiyqmizaiyqmiz

                1




                1




                New contributor



                aiyqmiz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.




                New contributor




                aiyqmiz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.
























                    Pratik Kale is a new contributor. Be nice, and check out our Code of Conduct.










                    draft saved

                    draft discarded


















                    Pratik Kale is a new contributor. Be nice, and check out our Code of Conduct.













                    Pratik Kale is a new contributor. Be nice, and check out our Code of Conduct.












                    Pratik Kale is a new contributor. Be nice, and check out our Code of Conduct.
















                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f519625%2fpassing-bash-array-to-python-script%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

                    Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

                    Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...