Skip to main content

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?

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



#!/bin/sh

ADMIN_USER_ENCRYPTED="$4"

echo "${ADMIN_USER_ENCRYPTED}"

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}"

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?


Reply