我不知道你的代碼有什麼問題。它應該工作。我測試了它:
$ sqlplus '/as sysdba' <<_EOF1_ >sql.log
spool '/home/oracle/test1.log'
select * from dual;
spool off;
exit;
_EOF1_
輸出
$ cat sql.log
SQL*Plus: Release 11.2.0.4.0 Production on Mon Nov 6 15:18:42 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
SQL> SQL>
D
-
X
SQL> SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
輸出2
$ cat /home/oracle/test1.log
SQL> select * from dual;
D
-
X
SQL> spool off;
有兩種選擇acomplish你的目標。你在一個使用兩個。有什麼理由呢?
選項1
$ sqlplus/as sysdba <<EOF> /dev/null
spool test.out
select * from dual;
spool off
EOF
輸出
$ cat test.out
SQL> select * from dual;
D
-
X
SQL> spool off
選項2
$ sqlplus/as sysdba <<EOF> test.out
> select * from dual;
> EOF
輸出
$ cat test.out
SQL*Plus: Release 11.2.0.4.0 Production on Mon Nov 6 15:12:05 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
SQL>
D
-
X
SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
更詳細地描述你的問題。預期產出是多少?這是什麼意思「無法獲得」?你遇到什麼錯誤? – tambre
第一部分,EOF到EOF工作,但第二部分_EOF1_,運行腳本時可運行 –
,RMAN部分已成功完成,出現錯誤:./rmanrecover.sh:第19行:警告:此處 - 第13行的文檔在第13行(想要'_EOF1_'),並且不運行sqlplus部分,但是當rman部分被寫入一個腳本中,並且相同的sqlplus部分被寫入其他腳本並且從rman腳本調用sqlplus腳本成功地工作。 –