Re: Expect timeout problem. I needs help.



zelzel.zsu@xxxxxxxxx wrote:
I am new to expect and tcl.

All .. I want to do is: spawn su and  chech my root password.

But when i run the script. sometimes the root password was accepted.
sometimes the expect timeout, with dit not verify the root password.

So this script simply could not work.
1. what is time source of timeout problem?
2. how to solve it?

thanks.

the source: root.cl <<<<<<<<<<<<<<

[brian@brian brian]$ cat root.tcl #!/usr/local/bin/expect -f

# 1. start su interpreter
spawn     "su"
set     timeout     5
expect "Password"  {  send  "google\r"}

Are you shure this is what your su cmd tells you? Mine says: "Password: "

If you do not expect the ":" and "<space>" after "Password"
you send the password while su is still talking to you.
This is impolite and su goes into a sulk.
Actually it discards all input received when finished with
sending the prompt and then waits for your input in nonecho mode .

uwe
.



Relevant Pages

  • Expect timeout problem. I needs help.
    ... spawn su and chech my root password. ... sometimes the expect timeout, with dit not verify the root password. ... So this script simply could not work. ...
    (comp.lang.tcl)
  • Re: scp failing
    ... When you run scp from the command line, ... taking out the timeout block does *not* remove ... script and the suggested fixes, ... this script is running another script on a remote computer. ...
    (comp.lang.tcl)
  • Re: Script Time Out Issue
    ... I am suspicious of the ODBC - I checked on the ODBC timeout and it relates ... then produces an error message that it failed to perform one of the LMS API ... seconds recovered and the script ran to completion. ...
    (microsoft.public.windows.server.scripting)
  • Re: bourne shell user interaction
    ... I have a script which loops but I'd like it to see if the user wants to ... I think read and expect can't timeout so I couldn't see how they could ... If the exit code is 0, the user pressed a key within the timeout period. ...
    (comp.unix.shell)
  • Re: scp failing
    ... When you run scp from the command line, ... taking out the timeout block does *not* remove ... script and the suggested fixes, ... this script is running another script on a remote computer. ...
    (comp.lang.tcl)