I am trying to substitute a unix variable to a select statement, but I am getting the below error. What did I do wrong?
sqlplus "/ as sysdba" << EOF
spool /home/oracle/l.log
archive log list;
exit;
EOF
Adest=`cat /home/oracle/l.log |head -4|tail -1|awk '{print $3}`
sqlplus "/ as sysdba" << EOF
spool /home/oracle/register.lst
select 'alter database register logfile '||''''||$Adest||'/1_'||sequence#||'_915925946.dbf'||'''' from v\$archived_log where applied='NO';
@ /home/oracle/register.lst
exit;
EOF
Error Log:-
SQL> select 'alter database register logfile '||''''||||'/1_'||sequence#||'_915925946.dbf'||'''' from v$archived_log where applied='NO';
select 'alter database register logfile '||''''||||'/1_'||sequence#||'_915925946.dbf'||'''' from v$archived_log where applied='NO'
*
ERROR at line 1:
ORA-00936: missing expression
SQL> @ /home/oracle/register.lst
SQL> exit;
cat /home/oracle/l.log|head -4|tail -1|awk {'print $3'}
/u01/app/oracle/DG1_ARCH
cat spool /home/oracle/l.log|head -3|tail -1|awk '{print $3}
can be replace byawk 'NR==3 { print $3} ' spool /home/oracle/l.log
$Adest
is set ?echo $Adest
before calling sql ?sqlplus "/ as sysdba"
bycat
, does the value for$Adest
is set ? if no, tryAdest=$( ... )
instead of backquote.