Variable is not substituting values


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Variable is not substituting values
# 1  
Old 09-07-2011
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.

Code:
#!/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

# 2  
Old 09-07-2011
Code:
 
#!/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

# 3  
Old 09-07-2011
even then , it turns out of no use. thanks for your help, anyway.

Code:
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

# 4  
Old 09-07-2011
Code:
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>

# 5  
Old 09-07-2011
You'll need:
Code:
#!/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

# 6  
Old 09-07-2011
The shell tries to subsitute $SID_. Enclose your variablenames in curly braces.
Code:
#!/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...

Last edited by radoulov; 09-07-2011 at 07:44 AM.. Reason: Code tags fixed.
This User Gave Thanks to cero For This Post:
# 7  
Old 09-07-2011
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!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

getting error while substituting variable using sed..

I am using script for substitute one variable with another variable like below... below code works fine... sed 's/'$sub_fun'/'$To_sub'/g' But when i run the same code from the script getting below errors.. sed: -e expression #1, char 7: unterminated `s' command please help....... (2 Replies)
Discussion started by: pamu
2 Replies

2. Shell Programming and Scripting

Trouble with sed and substituting a string with special characters in variable

Hey guys, I know that title is a mouthful - I'll try to better explain my struggles a little better... What I'm trying to do is: 1. Query a db and output to a file, a list of column data. 2. Then, for each line in this file, repeat these values but wrap them with: ITEM{ ... (3 Replies)
Discussion started by: ampsys
3 Replies

3. Shell Programming and Scripting

Substituting a shell variable in sed

Hi guys, I'm trying to figure out how to use a shell variable inside my sed command. I just want to remove a certain part of a path. I've tried three different combinations and none of them work. Here are the three combinations: echo $file | sed 's/'$test'//' echo $file | sed "s/$test//"... (7 Replies)
Discussion started by: chu816
7 Replies

4. Shell Programming and Scripting

Substituting a word by different word in variable

Hello Exprets, I have a requirement where i have to subtitue a word with another word. $eachline| sed 's/*$//' a) $eachline will hold a value a path for example user/oracle/Test_admin/myfolder/bakup/part_bkptemp_part_bkp_repeated/list.txt b) $eachline| sed 's/*$//' will give me the... (3 Replies)
Discussion started by: aks_1902
3 Replies

5. UNIX for Dummies Questions & Answers

substituting variable value in AWK

Hi All, my requirement is as below. I need to replace a value in a particular column with a substitution variable(date value) and modified value of the current column value in the same position. for ex. i have a record like 02;aaaa;bbbbb;cccccc;dddddd;123456789;hhhhh;12hs;asdf ;... (3 Replies)
Discussion started by: ganesh_248
3 Replies

6. Shell Programming and Scripting

Substituting the values

Hi Gurus this is working finee with tested values #!/bin/ksh V_DATE="2007-11-30" V_ID=789 V_NAME="john_${V_ID}_has_${V_DATE}_s" FILE_NAME=`echo ${V_NAME}` echo ${FILE_NAME} Buttt the problem is the first two values will come dynamically and the file will looks like... (2 Replies)
Discussion started by: SeenuGuddu
2 Replies

7. Shell Programming and Scripting

Reading variable from file variable values

Hi, Here is the output of lpstat. I would like to read value of Queue which is(abxxxxb1)and status that is DOWN in first line. i dont care what is in second line. any one can help me.thanks Queue Dev Status Job Files User PP % Blks Cp Rnk ------- ----- ---------... (5 Replies)
Discussion started by: sagii
5 Replies

8. Shell Programming and Scripting

Substituting variable value in AWK /start/,/stop/

Hi all u brilient people on the forum... I am trying to call the variable value in awk command for search pattern /start/,/stop/ but i am nt able to do this .... wat i did is ..i have created two variable YESTERDAY and TODAY and passed the y'day n 2'days dates in it...like this ... (14 Replies)
Discussion started by: whomi
14 Replies

9. Shell Programming and Scripting

Substituting with value of variable in Sed

Hi, I have a program in which i have to substitute a TAG in a file with the value of a variable. Code Snippet: ---------------- myvar=1234 sed 's/_TAG_/$myvar/' infile outfile When I run this command, the _TAG_ in the "infile" is substituted with "$myvar" but NOT the value "1234"... (1 Reply)
Discussion started by: jyotipg
1 Replies

10. Shell Programming and Scripting

Substituting variable with current time

Hi all I have a script as follows :- #!/usr/bin/ksh IDT=`date +"%OH%M%S"` while true do echo ${IDT} sleep 1 done I need the time to show me the current runtime value for the time, however this returns the time as at the start of the script. Any ideas. Thanks JH (4 Replies)
Discussion started by: jhansrod
4 Replies
Login or Register to Ask a Question