我有两个脚本,或者最好将一个脚本称为另一个脚本的包装器。
这是包装器:
#!/usr/bin/expect
set timeout 20
spawn "./installOracleDatabase.sh"
expect "replace Disk1/upgrade/gen_inst.sql?" { send "N\r" }
expect "Specify the HTTP port that will be used for Oracle Application Express" { send "\r" }
expect "Specify a port that will be used for the database listener" { send "\r" }
expect "initial configuration:" { send "root\r" }
expect "Confirm the password:" { send "root\r" }
expect "Do you want Oracle Database 11g Express Edition to be started on boot" { send "y\r" }
这是主要脚本:
#!/bin/bash
#install required libraries and programs
sudo yum -y install libaio bc flex unzip
#unzipping the Oracle package
unzip -q oracle-xe-11.2.0-1.0.x86_64.rpm.zip
cd Disk1
sudo rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm
sudo /etc/init.d/oracle-xe configure
cat " . /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh" >> $HOME/.bashrc
第二个脚本的问题是,在 的最后一步之后sudo /etc/init.d/oracle-xe configure
,当配置脚本询问“您希望 Oracle (...) 在引导时启动”时,就在该步骤之后,在正常安装过程中,Oracle 是执行其他一些步骤:
Do you want Oracle Database 11g Express Edition to be started on boot (y/n) [y]:y
Starting Oracle Net Listener...Done
Configuring database...Done
Starting Oracle Database 11g Express Edition instance...Done
Installation completed successfully.
这一步需要一些时间。但我的脚本在回答完y
最后一个问题后立即退出......
如何强制脚本等待整个配置完成?
答案1
为了使脚本等到Oracle最后一步,您可以尝试将以下行添加到脚本expect
末尾expect
expect "Starting Oracle Net Listener...Done" { send "\r" }
expect "Configuring database...Done" { send "\r" }
expect "Starting Oracle Database 11g Express Edition instance...Done" { send "\r" }
expect "Installation completed successfully." { send "\r" }
expect eof