0

I have a script that connects to Openshift and launches a series of commands on PODs. Since I am working with multiple PaaS, I need to launch the script on each of them with a different connection command

If I do this in sequence all works fine but it takes a very long time so I prefer to launch all commands in parallel

Launching them in parallel in the same environment causes the connections to overwrite each other

I found this article How to run a program in a clean environment in bash? on here that seems promising, however it does not allow me to send arguments to the script I'm launching

My code looks like this at the moment:

#Get argument values
...
env -i ~/Path/To/script.sh -a1 value -a2 ${variable1} -a3 ${variable2} -- --noprofile -norc &
env -i ~/Path/To/script.sh -a1 value -a2 ${variable1} -a3 ${variable2} -- --noprofile -norc &
env -i ~/Path/To/script.sh -a1 value -a2 ${variable1} -a3 ${variable2} -- --noprofile -norc &
env -i ~/Path/To/script.sh -a1 value -a2 ${variable1} -a3 ${variable2} -- --noprofile -norc &
...
#Process resulting output

In this scenario script.sh does not seem to receive the argument values sent as variables

Any ideas on how I can get the variable arguments through knowing that I cannot write their value in the script as it is sensitive information?

Thank you all in advance,

Regards, Jean

1 Answer 1

0

The two options --norc and --noprofile are options for the bash interpreter. This means that you will have to call the interpreter explicitly to pass these options to it:

env -i bash --norc --noprofile ~/Path/To/script.sh -a1 value -a2 "$variable1" -a3 "$variable2"

Here I've also taken the freedom to both add quotes around the unquoted variables in your command and delete the unnecessary curly braces.

3
  • Thanks for the quick reply Kusalananda, I'm afraid this did not fix the issue, I still see that arguments a2 and a3 are not passed to the scripts. It's as if the variable defined in the script calling those is not defined when calling them.
    – BNT
    Feb 20 at 10:13
  • @BNT A test with a script containing the single command print '"%s"\n' "$@" (prints each individual argument quoted on a line) shows that the arguments are passed. I don't know what your script is doing, but if it's resetting the list of positional parameters, then you would obviously loose the arguments.
    – Kusalananda
    Feb 20 at 10:38
  • 1
    Indeed the arguments were passed, the error message I was getting was a false positive caused by another issue. Thanks for your support
    – BNT
    Feb 21 at 13:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .