Link to home
Start Free TrialLog in
Avatar of whoopwhoop2015
whoopwhoop2015

asked on

How to pass variables from shell script to sqlplus

How can I pass in newValue to sqlplus from shell?  It keeps erroring out due to $1 and like characters which are a random value assigned to newValue in database.

newValue= $2a$10$1Qect

#!/bin/ksh

common_pass=password

for db_user in db1/user1 db2/user2 db3/user3 db4/user4 db5/user5 db6/user6
do
  db=`echo $db_user | cut -f1 -d/`
  user=`echo $db_user | cut -f2 -d/`
  $ORACLE_HOME/bin/sqlplus ${user}/${common_pass}@${db} << EOF
select * from tab
where idValue = $newValue;
EOF
done

Open in new window

Avatar of ozo
ozo
Flag of United States of America image

newValue='$2a$10$1Qect'
Avatar of whoopwhoop2015
whoopwhoop2015

ASKER

I tried adding newValue='$2a$10$1Qect' under common_pass=password and it gives me a missing expression error pointing to the first dollar sign.
try to add \ before $
I have tried newValue='\$2a$10$1Qect' and I get invalid character where idValue = \$2a$10$1Qect
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you ozo.  
newValue='$2a$10$1Qect'
where idValue = '$newValue';