Expect timeout problem. I needs help.



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"}

# 2. check password
set timeout 20
expect {
timeout { puts "wait su check Timeout"; exit }
"su: incorrect" { puts "Wrong Password"; exit }
"root" { puts "ROOT ACCEPT"; exit }
}
expect eof

[brian@brian brian]$

>>>>>>>>>>>> run timeout, with correct password <<<<<<<<<<<<<<<<<<<

[brian@brian brian]$expect -f root.tcl
spawn su
Password: google
wait su check Timeout


>>>>>>>>>>>>>>>>> run ok. as expected. <<<<<<<<<<<<<<<<<<<<
[brian@brian brian]$expect -f root.tcl
spawn su
Password: google

[root@brian brian]$ROOT ACCEPT
[brian@brian brian]$

.



Relevant Pages

  • Re: Expect timeout problem. I needs help.
    ... sometimes the expect timeout, with dit not verify the root password. ... So this script simply could not work. ...
    (comp.lang.tcl)
  • Re: How to extract part of what matched an expect pattern?
    ... You seem to be missing a [spawn] in there... ... and in my simplified script, I didn't pay attention to spawning. ... timeout ... But when I hardcode the $hostname ...
    (comp.lang.tcl)
  • Re: Spawn time-out
    ... I have an expect script which spawns a process to rsync a directory on ... To handle errors caused by the spawn, I put various patterns, ... Does anyone know why Expect would call a timeout handler even though ...
    (comp.lang.tcl)
  • Summary: random generator to change root password regularly - scripting help needed
    ... Many asked why need a root password if system admins dont need ... script I have all the passwords and encrypt it and check agains the ... Expect comes with a script called autopasswd so you would not need Perl. ... > application that would fail if the root password expires. ...
    (SunManagers)
  • Re: Setting Up NTP for Time Sync
    ... > I've made no changes to the script file that I know of. ... called iptables after the command "iptables" that manipulates the ... The /etc/init.d/ntpd script is the one run when ntpd is started. ... [enter root password] ...
    (comp.os.linux.networking)