SQLPLUS in script

I have a script that passes a parameter to the sqlplus command that looks like the following:

#!/bin/sh

TARGET_SID=$1
AUXILIARY_SID=$2
sqlplus 'sys@$AUXILIARY_SID as sysdba' @shutdown.sql

I keep getting the following error:
ERROR:
ORA-12154: TNS:could not resolve service name
HOWEVER, I have my sid defined in the tnsnames.ora AND if I take out the parameter $AUXILIARY_SID and put in the actual sid name (PPRD) it works fine. Any Ideas?

Thanks!
Rhonda Nichols

Use double quotes rather than single quotes.

Thanks. I never thought of somthing so simple. One more thing. I am trying to pass the pswd as a parameter so that it doesn't so up during ps -ef as follows:

PSWD=***** (where stars are my password)
sqlplus "sys@$AUXILIARY_SID as sysdba" @shutdown.sql <$PSWD

but of course this doesn't work. Can this be done? What am I doing wrong?

-Rhonda

Sorry, I had a DUH moment.

I just did this:

sqlplus "sys/$PSWD@$AUXILIARY_SID as sysdba" @shutdown.sql

I think this will work

THANKS!

An alternative is:

echo $PSWD | sqlplus "sys@$AUXILIARY_SID as sysdba" @shutdown.sql

or you can use a named pipe:

mknod p sysdba_logon.sql
echo "connect sys/$PSWD@$AUXILIARY_SID as sysdba" > connect.sql &
sqlplus <<-EOF
@connect.sql
@shutdown.sql
EOF
rm connect.sql