Re: SSH login automation, get stuck at the last step.



Schubert wrote:

But when I use Expect script above to automate the manual steps, it
will get stuck running the batch file. It simply shows the
[root@<Server Name>: <Server IP address>] prompt and then stops. Does
anybody know why this happens? Greatly appreciated.

Nothing expected, nothing shown.

[expect] the batch completion message
expect $batch_message
and then the prompt.
expect $prompt

then exit
exp_send "exit\r"
expect eof


with expecting some output it may be a good idea to expect
timeouts and errormesssages like:

exp_send $runbatchline\r
set ::JOB "not done"
expect \
$batchokmsg {
puts "batch run OK"
set ::JOB OK
# need prompt, continue will restart this expect
exp_continue
} $batcherrormsg {
puts "error in batch"
set ::JOB ERR
# you are still waiting for the prompt right?
exp_continue
} $prompt {
puts "back at the prompt JOB stat: $::JOB "
} timeout {
puts "sleeping at the job $::JOB ?"
}

something like the above, adapt to your case.

uwe
.