scripts behave differently [message #152933] |
Wed, 28 December 2005 00:22 |
tarundua
Messages: 1080 Registered: June 2005 Location: India
|
Senior Member |
|
|
I wrote a shell script to spool out the filenames associated with the specified tablespace.
SCRIPT1
## scrpt1.sh
if [ $# -ne 2 ]
then
echo invalid arguments
exit
else
tblsp_name="$1"
log_str="sys/$2 as sysdba"
val=`sqlplus -S "$log_str" <<!
set heading off
set feedback off
spool tmp_fl.out
select file_name from dba_data_files
where tablespace_name=upper('$tblsp_name');
spool off
!`
fi
the above works perfectly.
but SCRIPT2
## scrpt2.sh
if [ $# -ne 2 ]
then
echo invalid arguments
exit
else
tblsp_name="$1"
log_str="sys/$2 as sysdba"
sqlplus -S "$log_str" <<!
set heading off
set feedback off
spool tmp_fl.out
select file_name from dba_data_files
where tablespace_name=upper('$tblsp_name');
spool off
!
fi
this generates an error
[oracle@localhost ~]$ ./scrpt2.sh users passwd
./scrpt2.sh: line 18: syntax error: unexpected end of file
the only difference is , assigning the output of sqlplus session to a variable i.e. val (first script).
I want to know why the second script is not working or what i am doing wrong in the second script.
thanks & regards,
tarun
|
|
|
|
Re: scripts behave differently [message #152966 is a reply to message #152965] |
Wed, 28 December 2005 02:54 |
tarundua
Messages: 1080 Registered: June 2005 Location: India
|
Senior Member |
|
|
Hi Frank,
Bingo.. You hit the right spot. I changed the position of ! and look it works perfectly fine.
[oracle@localhost ~]$ ./scrpt2.sh users passwd
/data/dev_database/datafile/users01.dbf
Any specific reason for this behaviour.
Regards,
tarun
|
|
|
|
|