红联Linux门户
Linux帮助

shell脚本中生成的spool文件没有执行的语句

发布时间:2016-09-10 15:20:44来源:linux网站作者:丹心明月
代码:
#!/bin/bash  
#start on 20160909  
#auto_check.sh  
#liming  
#aim to do db check automatically  
#usage:  
su - oracle -c 'sqlplus -s / as sysdba'<< EOF   >>/u01/app/oracle/script_test_result/auto_check.log 2>1  
set echo on  
set feedback on  
spool /home/oracle/script_test_result/auto_check.log  
select * from lm.lm_t1;  
spool off  
exit  
EOF  
 
生成的spool文件auto_check.log里面,没有我执行的语句。这个怎么搞呀?  
[root@single1 script_test_result]# more auto_check.log   
no rows selected  
 
由于对一些命令的不熟悉,导致了我在这个问题上纠结了很久。后来查了许多资料,发现,其实不是set echo on 的问题,而是连接语句的问题。
sqlplus -s / as sysdba  
 
中的-s,查了一下命令,我懂了。
-S  Sets silent mode which suppresses the display of the SQL*Plus banner, prompts, and echoing of commands.  
 
果断将-s去掉,然后就恢复了。
[oracle@single1 script_test_result]$ cat auto_check.log   
SQL> select * from dual;  
X  
1 row selected.  
SQL> spool off
 
本文永久更新地址:http://www.linuxdiyf.com/linux/24043.html