Results 1 to 7 of 7
Hi all,
I wrote the following expect script:
#!/usr/bin/expect
spawn /tools/bin/hongkong.sh
expect "Enter your input>"
send "1"
send "\n"
expect "User:"
send "<user_name>"
send "\n"
expect "password:"
send "<password>"
send ...
- 09-03-2008 #1Just Joined!
- Join Date
- Oct 2007
- Posts
- 5
Need help in introducing a delay in an expect script
Hi all,
I wrote the following expect script:
#!/usr/bin/expect
spawn /tools/bin/hongkong.sh
expect "Enter your input>"
send "1"
send "\n"
expect "User:"
send "<user_name>"
send "\n"
expect "password:"
send "<password>"
send "\n"
expect "Enter your choice:"
send "1"
send "\n"
sleep 1
interact {
}
I got the following error while executing the script:
Enter your choice: invalid command name: "sleep"
while executing
"sleep 1"
(file "harlow" line 15)
Basically, I want to introduce a delay after sending the "1".
Is there a way I can introduce a delay the expect script?
Thanks,
Ayyappa
- 09-03-2008 #2
Try putting a spawn command in front of the sleep.
Debian GNU/Linux -- You know you want it.
- 09-04-2008 #3Just Joined!
- Join Date
- Oct 2007
- Posts
- 5
Could you please provide me the syntax for Spawn command?
I am new to this expect scripting.
- 09-04-2008 #4Just Joined!
- Join Date
- Aug 2008
- Location
- Seattle, WA
- Posts
- 46
its usually just 'sleep <number of seconds>'
- 09-06-2008 #5
- 10-08-2008 #6Just Joined!
- Join Date
- Oct 2008
- Posts
- 2
instead of sleep, please use "set timeout n", where "n" is the number of seconds after which you want to timeout
Example: set timeout 5
this will wait till 5 secs and then timeout to proceed to the next set of actions
- 10-08-2008 #7Just Joined!
- Join Date
- Oct 2008
- Posts
- 2
Example for spawn:
spawn bash
spawn ksh
spawn rlogin $server -l $userid


Reply With Quote
