Note that there are some explanatory texts on larger screens.

plurals
  1. POExpect script does not exit after completion
    text
    copied!<p>I have the following situation.</p> <p>My main <strong>expect</strong> script looks something like this</p> <pre><code>#!/usr/bin/expect -d set timeout 900 spawn main_ksh_script.ksh [lindex $argv 0] expect { "Press ENTER to Continue" { send_user "Message1\n" send "\r" exp_continue} "Press any key to continue" { send "\r" exp_continue} eof { send "\003\177\015" send_user "EOF reached\n" exit 0} timeout { send_user "Job timed out\n" send "\003\177\015" exit 100} } interact { \015 {send "\015"} \003 {send "\003\177\015"} "\033\[3~" {send "\177"} } </code></pre> <p>My main <strong>korn</strong> shell script (main_ksh_script.ksh) is a really huge script that does many things to the desired environmet. One of those things is running deamons and some remote jobs. Here's very short example...</p> <pre><code>while true; do clear echo "\n\tDo You Want to deploy xxx!!! ([Yes]/No) \c" read yn1 ; case ${yn1} in [Yy]*|$enter) clear echo "SomeJobName1" on Environment (${envNum})\n" secondScript.expect environment$envNum@host "Some command(s)" echo "End of SomeJobName1" on Environment (${envNum})\n" echo "SomeJobName2" on Environment (${envNum})\n" secondScript.expect environment$envNum@host "Some command(s)" echo "End of SomeJobName2" on Environment (${envNum})\n" #And so on... break ;; [Nn]*) break ;; *) echo "\n\tPlease choose Yes or No\c"; pau ;; esac pau done </code></pre> <p>secondScript.expect looks something like this...</p> <pre><code>#!/usr/bin/expect -d set timeout 300 spawn ssh -o PubkeyAuthentication=no [lindex $argv 0] -n [lindex $argv 1] expect { "Operational Job ended successfully" { send "\003\177\015" exp_continue} "Operational Job ended with failure" { send "\003\177\015" exp_continue} "Press ENTER to Continue" { send "\r" exp_continue} "Press any key to continue" { send "\r" exp_continue} "Password:" { send "mypassword\r" exp_continue} eof { send "\003\177\015" send_user "EOF reached\n" exit 0} timeout { send "\003\177\015" exit 100} } interact </code></pre> <p>Problem is, that when the main_ksh_script.ksh finishes, the first expect script (the one that invoked it by spawning a process) does not exit. I have to opet new terminal, and kill it by "kill -9". Can't even send Ctrl+c.</p> <p>Edit... If I remove "interact" from both expect scripts, I got no results. This is how the tail of the main script looks like.</p> <pre><code>expect: does " \c\r\n\r\n" (spawn_id exp6) match glob pattern "Press ENTER to Continue"? no "Press any key to continue"? no expect: read eof expect: set expect_out(spawn_id) "exp6" expect: set expect_out(buffer) " \c\r\n\r\n" </code></pre> <p>It still won't terminate by itself, and I still can not kill it by any other way, expect by kill command from another terminal.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload