スクリプトが操作の完了を「待機」するようにするにはどうすればよいですか?

スクリプトが操作の完了を「待機」するようにするにはどうすればよいですか?

スクリプトが 2 つあります。あるいは、1 つをもう 1 つのラッパーと呼ぶ方が適切かもしれません。

ラッパーはこちらです:

#!/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

2 番目のスクリプトの問題は、 の最後のステップの後で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

関連情報