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
.



Relevant Pages

  • Re: SSH login automation, get stuck at the last step.
    ... will get stuck running the batch file. ... and then the prompt. ... When I execute my script on the top, ... Does anybody know about using Expect to do ssh login and then run any ...
    (comp.lang.tcl)
  • Re: SSH login automation, get stuck at the last step.
    ... will get stuck running the batch file. ... and then the prompt. ... with expecting some output it may be a good idea to expect ... filename.txt" command. ...
    (comp.lang.tcl)
  • Re: SMS Package Hangs on client
    ... The batch file hangs prompting for a password when trying to make a drive ... or local machine account it hangs since that share has permissions assigned. ... Since the batch was hanging waiting for a prompt, it wouldn't time out in the ... >> and as a mandatory package to be run as soon as possible. ...
    (microsoft.public.sms.swdist)
  • Re: SSH login automation, get stuck at the last step.
    ... Have you tried to adapt the script I wrote in a previous post? ... It still stops at the prompt ... with two same "run batch filename.txt" command, ... beginning of the line that the prompt resides, the other command is ...
    (comp.lang.tcl)
  • Re: SSH login automation by Expect, get stucked at last step....Help!!!
    ... Then run a batch file. ... Expect has a "-exact" flag to its expect command. ... perhaps to make the prompt appear in a different colour. ... first attach the script afterwards, ...
    (comp.unix.shell)