작업이 완료될 때까지 스크립트를 "대기"하려면 어떻게 해야 합니까?

작업이 완료될 때까지 스크립트를 "대기"하려면 어떻게 해야 합니까?

두 개의 스크립트가 있습니다. 하나를 다른 하나의 래퍼라고 부르는 것이 좋습니다.

래퍼는 다음과 같습니다.

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

관련 정보