Posted on 05-03-2018 02:55 AM
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?
Posted on 05-03-2018 04:03 AM
It should work, we use it regularly. Is the script protecting (quoting) the characters?
#!/bin/sh
ADMIN_USER_ENCRYPTED="$4"
echo "${ADMIN_USER_ENCRYPTED}"
Posted on 05-03-2018 08:19 AM
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}"
Posted on 05-03-2018 08:42 AM
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?