2017-10-12 14 views
0

를 사용하여 쿼리 O를/P는없는 얻을 같은 :데시벨 프로세스 테스트를 회복하기위한, 내가 쉘 스크립트를 작성한 쉘 스크립트

#!/bin/bash 
#shell script for recovery testing 
$ORACLE_HOME/bin/rman target/ <<EOF >rman.log 
     shutdown immediate; 
     startup mount; 
     run 
     { 
       recover database; 
     } 
     sql 'alter database open read only'; 
exit; 
EOF 

$ORACLE_HOME/bin/sqlplus '/as sysdba' <<_EOF1_ >sql.log 
     spool '/home/oracle/test1.log' 
     select * from hr.employees; 
     spool off; 
exit; 
_EOF1_ 

하지만, 스풀을 어떻게 해결하는 SQL 쿼리의 출력을 얻을 수 없습니다 발행물?

+0

문제를 자세히 설명하십시오. 예상되는 결과는 무엇입니까? "얻을 수 없다"는 것은 무엇을 의미합니까? 발생한 오류가 무엇입니까? – tambre

+0

첫 번째 부분은 EOF에서 EOF로 작업하지만 두 번째 부분 인 _EOF1_은 스크립트를 실행하는 동안 –

+0

을 실행할 수 있습니다. RMAN 부분은 오류로 인해 성공적으로 완료되었습니다. ./rmanrecover.sh : 19 번째 줄 : 경고 : 여기 - 끝 부분으로 구분 된 13 번째 줄의 문서 -of-file ('_EOF1_ ')을 필요로하고 sqlplus 부분을 실행하지 않지만 rman 부분이 하나의 스크립트로 작성되고 동일한 sqlplus 부분이 다른 스크립트에 작성되고 rman 스크립트에서 sqlplus 스크립트를 호출하는 동안 정상적으로 작동합니다 . –

답변

0

코드에 어떤 문제가 있는지 알 수 없습니다. 그것은 작동해야합니다. 나는 그것을 테스트 :

$ 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