Shell脚本:调用runInstaller的时候容易出现的一个问题
在使用Shell脚本调用Oracle的安装程序runInstaller的时候,总会因为runInstaller执行完系统检查后,回到提示符,然后再调用安装介质的“install/.oui”,导致真正执行oui的时候,其实引用runInstaller的shell早已经执行完了,而无法达到预期。
在我的这里,表现为这样:
我之前的开机自动配置脚本也正是因为这个原因。所以在脚本中,写了后续的netca与dbca的静默配置,却始终报找不到netca与dbca指令的原因。因为,脚本执行的时候,软件还没有装好,脚本执行完了,oui才开始安装。
对于这个问题,可以在调用runInstaller之后,用一个while循环监视oui进程的状态,让脚本持续睡眠,直到oui的静默安装结束,来解决。
具体如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
[root@rhel510 pub]# cat temp_me/script_lab/keep_until_done # Script: keep_until_done echo -e "begin: "`date` su - oracle -c "/software/oracle_media/database/runInstaller -silent -ignoreSysprereqs -responseFile /script/oracle_enterprise_sw_only.rsp" count_while=1 while [ `ps -ef | grep -v grep | grep oracle | grep oui | wc -l` != 0 ] do echo "@@@ Process is still working... Now: $count_while" # increase count number. let count_while=count_while+1 # if process not done, keep sleep 20's echo "--- sleep: 20 second." echo "" sleep 20 done echo -e "end: \t"`date` [root@rhel510 pub]# |
————————————————
Done。