Cannot get JSS parameters 10 or 11 to work

bpavlov
Honored Contributor

Save this simple script as parameter_test.sh to your desktop.

#!/bin/bash

process1="$5"
process2="$6"
process3="$7"
process4="$8"
process5="$9"
process6="$10"
process7="$11"

echo "$process1"
echo "$process2"
echo "$process3"
echo "$process4"
echo "$process5"
echo "$process6"
echo "$process7"

Then run the command sudo jamf runScript -script parameter_test.sh -path "~/Desktop/Packages/Scripts" -p1 "test0" -p2 "test1" -p3 "test3" -p4 "test4" -p5 "test5" -p6 "test6" -p7 "test7" -p8 "test8"

The result I get is:

Running script parameter_test.sh...
Script exit code: 0
Script result: test1
test3
test4
test5
test6
/0
/1

What am I doing wrong? I understand typically variables should not start with numbers in bash but I assume if its been this way for a while that it must work for other people as is.

3 REPLIES 3

mm2270
Legendary Contributor III

Ah, I once had this same problem and the good folks here helped me solve it! The solution: Enclose the parameters in curly brackets, at least for anything with a double digit, like this:

process6="${10}"
process7="${11}"

The problem is the expansion of the param happens once it sees $1 in both cases, so it ends up printing /0 (for $10) and /1 (for $11) Or something like that.
BTW, here's the old thread where I asked this same question: https://jamfnation.jamfsoftware.com/discussion.html?id=4991

bpavlov
Honored Contributor

You are a gentleman and a scholar. Thank you so much. That did it for me.

amosdeane
New Contributor III

Thanks also from me. Have been fighting with a script for a while and concluded that there was an issue with these variables. Good to be able to get it working!