Expect timeout problem. I needs help.
- From: zelzel.zsu@xxxxxxxxx
- Date: 28 Nov 2005 19:58:02 -0800
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]$
.
- Follow-Ups:
- Re: Expect timeout problem. I needs help.
- From: Uwe Klein
- Re: Expect timeout problem. I needs help.
- Prev by Date: Re: string handle problem
- Next by Date: Re: string handle problem
- Previous by thread: string handle problem
- Next by thread: Re: Expect timeout problem. I needs help.
- Index(es):
Relevant Pages
|