I'm using expect to start an application on my server:
#!/usr/bin/expect
set timeout -1
spawn "bin/start-all.sh"
expect {
-re "Found MongoDB in" { send "y\r"; exp_continue }
-re "Found Hadoop in" { send "y\r"; exp_continue }
-re "Going to start Hadoop" { interact }
}
I can access the application on my server in the few seconds while the script is running, but as soon as it ends the application becomes unavailable.
I've run expect in debug mode and get the following output towards the end:
expect: does "vendors area. Do you want to start it? [y/n] y\r\n" (spawn_id exp6) match regular expression "Found MongoDB in"? Gate "Found MongoDB in"? gate=no
"Found Hadoop in "? Gate "Found Hadoop in "? gate=no
"Going to start Hadoop"? Gate "Going to start Hadoop"? gate=no
Going to start Hadoop...
expect: does "vendors area. Do you want to start it? [y/n] y\r\nGoing to start Hadoop...\r\n" (spawn_id exp6) match regular expression "Found MongoDB in"? Gate "Found MongoDB in"? gate=no
"Found Hadoop in "? Gate "Found Hadoop in "? gate=no
"Going to start Hadoop"? Gate "Going to start Hadoop"? gate=yes re=yes
expect: set expect_out(0,string) "Going to start Hadoop"
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) "vendors area. Do you want to start it? [y/n] y\r\nGoing to start Hadoop"
tty_raw_noecho: was raw = 0 echo = 1
interact: received eof from spawn_id exp6
tty_set: raw = 0, echo = 1
tty_set: raw = 5, echo = 0
I've tried using exit 0
, interact
, exp_continue
, disconnect
, sleep 10
under the last pattern, as well as expecting eof
but nothing seems to be working. I've also tried running expect start-all.exp &
but that doesn't work either.
When I run bin/start-all.sh manually, the script starts the necessary processes and then exits. However with expect those processes seem to get killed. How would I fix this issue?
expect eof
at the end? – Edgewaysexpect_background
andexit 0
in the expect script but none get the parent expect script to end/exit. Only an interrupt (CTRL-C) ends it but I'm concerned it will also interrupt the spawned process (which I don't want to happen). – Disremember