Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Cold backups shell script
I am still having problems getting the shell script listed below to
work. I have tried putting the $controlfile between single quotes,
double quotes and just about everything else. I thought this would
work with the \ based on other people's posts but that is not the
case. I have tried both the bash shell on linux and ksh on Solaris
2.6. What is going on here? Anyone?
logFile='/tmp/logFile.log'
listFile='/tmp/listFile.log'
tmpFile='/tmp/tmpFile.log'
su oracle 2>>$logFile >>$logFile <<EOF_SQLPLUS
/opt/oracle/OraHome1/bin/sqlplus /nolog <<EOF_CONTROLFILE
connect / as sysdba
set echo off
set heading off
spool $listFile
select 'cp '||name|| ' /data/oracle/os_backups/homedb' from
v\$controlfile;
spool off
exit
EOF_CONTROLFILE
EOF_SQLPLUS
kennethkoenraadt_at_hotmail.com (Kenneth Koenraadt) wrote in message news:<1d765a2d.0211170740.288c5efb_at_posting.google.com>...
> Hi Steven,
>
> You did not provide your script code in your post, which you
> should....
>
> In a shell script (sh, ksh or bash) , the only way to avoid expansion
> of a $ is to put it into single quotes : '$<identifier>'.
>
> If you want to execute a sql statement from a shell script, the easist
> way is to put the statement into a file, script.sql, and then in your
> shell script :
> sqlplus user/pwd < script.sql > script.output
>
> Putting the sql code directly into the shell script is more
> complicated, but certainly doable. The main problem is, as you
> experience, that the shell script will try to expand some characters
> in the sql statements which should not be expanded.
>
>
>
> - Kenneth Koenraadt
>
>
> steven_at_alfisi.com (Steven Alfisi) wrote in message news:<a05aabfc.0211161901.32899cfb_at_posting.google.com>...
> > I am running Oracle 9i Enterprise Edition on SuSe linux 7.3 pro. I am
> > writing a shell script for a cold backup and the following line is
> > giving me an ORA-00942 table not found error...
> >
> > select 'cp '||name|| ' /data/oracle/os_backups/homedb' from
> > v\$controlfile;
> >
> > The log file that I am spooling too is saying that it's only
> > recognizing v as the table name. I thought the \ would allow the
> > $controlfile to be part of the table name. I also tried / just for
> > sh$ts and giggles. I am using the bash shell. Any ideas?
> >
> > Thanks in advance,
> > Steven
Received on Mon Nov 25 2002 - 14:06:55 CST