
Eu tenho dois scripts, ou talvez seja melhor chamar um de wrapper para o outro.
Aí vem o invólucro:
#!/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" }
E aqui está o script principal:
#!/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
O problema com o segundo script é que após a última etapa do sudo /etc/init.d/oracle-xe configure
, quando o script de configuração pergunta "Deseja que o Oracle (...) seja iniciado na inicialização", logo após essa etapa, durante a instalação normal, o Oracle é executando algumas outras etapas:
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.
Esta etapa está demorando algum tempo. Mas meu script está saindo logo após responder y
à última pergunta...
Como posso forçar o script a aguardar o término de toda a configuração?
Responder1
Para fazer com que o expect
script espere até a última etapa do Oracle, você pode tentar adicionar a seguinte linha ao final do expect
script
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