Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

joining values into one variable

Status
Not open for further replies.

eyetry

Programmer
Oct 2, 2002
560
0
0
US
Not a unix person but need to update unix/linux script.

Essenially, I added a new optional input parameter to a script. If the parameter has content I need to append it to another value for later use in the script.

if [ :p_ENCRYPTION_SIGNATURE = "" ]
then
set P_SIG = ""
else
set P_SIG = "--sign -u " :p_ENCRYPTION_SIGNATURE
fi
echo p_encrypt_sig value = :p_ENCRYPTION_SIGNATURE
echo signature = $P_SIG

The echoed value of p_sig ends up null. What is wrong?

p_encrypt_sig value = ddmn-3m-qa
signature =

 
What shell are you using? Unless it is C shell, try removing the "set"s and the spaces around the "=". Also, if P_ENCRYPTION_SIGNATURE is a variable (I presume it must be otherwise the if statement would always be false), then it needs to be prefixed by $ to obtain the value of the variable.

Something like this:

Code:
   if [ "$P_ENCRYPTION_SIGNATURE" = "" ]
    then
      P_SIG=""
    else
      P_SIG="--sign -u $P_ENCRYPTION_SIGNATURE"
    fi
    echo p_encrypt_sig value = $P_ENCRYPTION_SIGNATURE
    echo signature = $P_SIG




Annihilannic.
 
HA! Thanks, thought it was something easy. Tried removing 'set'. Didn't realize it was space sensitive.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top