Variable is not substituting values

Hi All,

OS HPUX 11.11

I am using following script to take controlfile backup. I have used SID variable to hold "ffin1" value, which I again subsitute in "'/db/ffin1/home/oraffin1/$SID_$wdate.ctl'" command. Well, after running this, SID variable does not subsittue it's value, while wdate subsitute.

the file is "090711.ctl' after running the following script.


#!/usr/bin/ksh
SID=ffin1
wdate=`date '+%m%d%y'`
sqlplus /nolog <<-EOF
conn / as sysdba
alter database backup controlfile to '/db/ffin1/home/oraffin1/$SID_$wdate.ctl' ;
EOF

 
#!/usr/bin/ksh
SID=ffin1
echo $SID #to check the value of SID
wdate=`date '+%m%d%y'`
sqlplus /nolog <<-EOF
conn / as sysdba
alter database backup controlfile to "/db/ffin1/home/oraffin1/$SID_$wdate.ctl" ;
EOF

even then , it turns out of no use. thanks for your help, anyway.


ffin1> ./ctl_bkp.sh

SQL*Plus: Release 8.1.7.0.0 - Production on Wed Sep 7 06:09:47 2011

(c) Copyright 2000 Oracle Corporation.  All rights reserved.

06:09:47 SQL> Connected.
06:09:47 SQL> alter database backup controlfile to "/db/ffin1/home/oraffin1/090711.ctl"
                                     *
ERROR at line 1:
ORA-00972: identifier is too long

SQL> alter database backup controlfile to "/my/path/backup/cntrl_backup.ora";
alter database backup controlfile to "/my/path/backup/cntrl_backup.ora"
                                     *
ERROR at line 1:
ORA-00972: identifier is too long


SQL> alter database backup controlfile to '/my/path/backup/cntrl_backup.ora';

Database altered.

SQL>

You'll need:

#!/usr/bin/ksh

SID=ffin1

echo $SID #to check the value of SID

wdate=$(
  date '+%m%d%y'
  )
  
sqlplus <<EOF
/ as sysdba

alter database backup controlfile to '/db/ffin1/home/oraffin1/${SID}_$wdate.ctl' ;

EOF

The shell tries to subsitute $SID_. Enclose your variablenames in curly braces.

#!/usr/bin/ksh
SID=ffin1
wdate=`date '+%m%d%y'`
sqlplus /nolog <<-EOF
conn / as sysdba
alter database backup controlfile to '/db/ffin1/home/oraffin1/${SID}_${wdate}.ctl' ;
EOF

Edit: radoulov was faster...

thanks a lot, it worked!

---------- Post updated at 06:15 AM ---------- Previous update was at 06:13 AM ----------

Thanks a lot !

---------- Post updated at 06:17 AM ---------- Previous update was at 06:15 AM ----------

Thanks a lot!