Skip to main content
Question

Cannot pass in special characters to script as parameter

  • May 3, 2018
  • 3 replies
  • 9 views

Forum|alt.badge.img+6

I have a script that require an input of randomized tokens sometime with special characters in it e.g:

ikXSqZ:{U,e,?v9:%~s#ak)tUFs7S1A+

Checked to print out the parameter value for that and nothing comes out.

Any idea how to pass these characters in?

3 replies

dsavageED
Forum|alt.badge.img+8
  • New Contributor
  • 173 replies
  • May 3, 2018

It should work, we use it regularly. Is the script protecting (quoting) the characters?

#!/bin/sh

ADMIN_USER_ENCRYPTED="$4"

echo "${ADMIN_USER_ENCRYPTED}"

Forum|alt.badge.img+6
  • Author
  • New Contributor
  • 2 replies
  • May 3, 2018

Hi @dsavageED

It is quoted as depicted below, but token variable is still empty.

#!/bin/sh
token=""
# Check if parameter $7 is assigned
if [ "$7" != "" ] && [ -z "$token" ]; then
    token="$7"
fi
echo "${token}"

dsavageED
Forum|alt.badge.img+8
  • New Contributor
  • 173 replies
  • May 3, 2018

I'm not sure why this isn't working for you. I added the code to my JSS and got the expected result (token was set to "ikXSqZ:{U,e,?v9:%~s#ak)tUFs7S1A+") after creating a test policy with the values set. I even tried a slight variation...

#!/bin/sh

token=""
# Check if parameter $7 is assigned
if [ "$7" != "" ] && [ -z "$token" ]; then
    token="$7"
fi
echo 7 "${token}" >> /Users/Shared/temp.text

tokn=""
# Check if parameter $6 is assigned
if ! [ -z "$6" ] && [ -z "$tokn" ]; then
    tokn="$6"
fi
echo 6 "${tokn}" >> /Users/Shared/temp.text

7 ikXSqZ:{U,e,?v9:%~s#ak)tUFs7S1A+
6 ikXSqZ:{U,e,?v9:%~s#ak)tUFs7S1A+

Are other parameters passing correctly?