呃。。。首先感谢您的解答。
不过我是要写一个shell脚本自动执行,如果手动输入命令是没问题的。
然后这里的问题是如果没有<<EOF...EOF时,会进入如你的idle>的SQL>处理行。
然后这时候我脚本里面要执行的命令,startup, connect~~便不能自动执行,处于等待输入状态。
然后手动退出SQL>处理行后,又提示:
./bash_db.sh: line 18: startup: command not found
./bash_db.sh: line 20: connect: command not found
我是想问如何实现这些命令,在SQL> 后执行。而不是退出后才执行。作者: iori809 时间: 2010-06-10 10:52 回复 9#chizhilove
[oracle@test7: ~]$more sh1.sh
#!/bin/bash
sqlplus "/nolog" <<EOF
conn / as sysdba
startup
select 1+1 from dual;
quit;
EOF
[oracle@test7: ~]$sh sh1.sh
SQL*Plus: Release 11.1.0.6.0 - Production on Thu Jun 10 10:53:55 2010
Copyright (c) 1982, 2007, Oracle. All rights reserved.
idle> Connected to an idle instance.
idle> ORACLE instance started.
Total System Global Area 839282688 bytes
Fixed Size 2149040 bytes
Variable Size 603981136 bytes
Database Buffers 226492416 bytes
Redo Buffers 6660096 bytes
Database mounted.
Database opened.
idle>
1+1
----------
2
idle> Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@test7: ~]$