0

After seeing the reactions on Stack Overflow on this question and an unfamiliarity with qsub, I believe thqt U&L is better suited for this question.

In qsub, we can pass environment variables (a comma-separated list of envar=value pairs) like so:

info="This is some info"
qsub -v INFO=$info script.pbs

However, this becomes problematic when $info contains a comma.

info="This is some info, and here is some more!"
qsub -v INFO=$info script.pbs

This will trigger an error like so:

ERROR: -v: variable ' and here is some more!' is not set in environment variables.

I have also tried encapsuling info, INFO="$info" leading to the same issue.

How can I pass $info correctly, even if it contains one or more commas? The same question holds with newlines which always end up incorrectly when they are passed (backslash gets removed).

Perhaps an interesting observation is that when I echo -e $info I get the output that I expect. The error is triggered in the qsub command specifically.

5
  • 1
    If you're on Bash, that unquoted INFO=$info will get word-split, likely making is, some etc. taken as filenames. The result should be quite different with and without the quotes. Commented Jul 5, 2023 at 5:47
  • 1
    Duplicate of stackoverflow.com/q/76616176/7552 Commented Jul 5, 2023 at 11:42
  • @glennjackman Yes, I made that explicit at the start. Commented Jul 5, 2023 at 11:49
  • In that case, please delete the instance over at stackoverflow. Cross-posting is strongly discouraged in the SE network and will lead to close-votes. Commented Jul 5, 2023 at 13:03
  • At the very least, link to it so people who want to answer here can see what has already been talked about there. Commented Jul 5, 2023 at 15:38

2 Answers 2

1

You can avoid this problem by giving only the variable name on the command line (which is visible to the command):

export INFO="This is some info, and here is some more!"
qsub -v INFO script.pbs

or

INFO="This is some info, and here is some more!" qsub -v INFO script.pbs
0
-4
qsub -v INFO="$info" script.pbs

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.