Using EXPECT to compare numerous lines 
Author Message
 Using EXPECT to compare numerous lines

When using expect and reading in from a vt100 telnet session, I wish to
verify that several lines of text are correct. Can anyone explain how this
could be done.

eg.
set send_slow {1.1}
spawn telnet 0.0.0.0
expect "Login:" {
   send -s "admin\r"

Quote:
}

expect "Password:" {
 send -s "admin\r"
Quote:
}

send -s "show info ip\r"
after 50

for example
What goes in next to match the following text using expect :-

                                                         Port Ip
PORT     IP_ADDRESS       NET_MASK         BROADCAST  REASM   ADVERTISE
=============================================================

Regards...........Steve



Tue, 26 Nov 2002 03:00:00 GMT  
 Using EXPECT to compare numerous lines
You might try this:

set timeout 10

expect {
  "Port Ip" { puts "1st line Ok."}
  timeout { puts "1st line incorrect."}

Quote:
}

expect {
  "PORT     IP_ADDRESS       NET_MASK         BROADCAST  REASM" { puts
"2nd line Ok."}
  timeout { puts "2nd line incorrect." }

Quote:
}

expect {
  "=============================================================" { puts
"3rd line Ok."}
  timeout { puts "3rd line incorrect." }

Quote:
}

It's a little crude, but it will work.

Cheers
Brad

Quote:

> When using expect and reading in from a vt100 telnet session, I wish to
> verify that several lines of text are correct. Can anyone explain how this
> could be done.

> eg.
> set send_slow {1.1}
> spawn telnet 0.0.0.0
> expect "Login:" {
>    send -s "admin\r"
> }
> expect "Password:" {
>  send -s "admin\r"
> }
> send -s "show info ip\r"
> after 50

> for example
> What goes in next to match the following text using expect :-

>                                                          Port Ip
> PORT     IP_ADDRESS       NET_MASK         BROADCAST  REASM   ADVERTISE
> =============================================================

> Regards...........Steve



Tue, 26 Nov 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How to compare two files line-by-line

2. Writng API using Expect for putting a break point on line in GDB

3. reading previous line using expect

4. sending files in-line through a telnet session using expect

5. How to run the expect script using TCL oe expect 5.21

6. Compare expect's argument names, How?

7. Q: Compare lines of files

8. Comparing Lines In Awk (Can I do this:)

9. Compare lines

10. assignment and compare on same line?

11. Using single puts line spanning serveral source lines

12. Newbies are numerous + 1

 

 
Powered by phpBB® Forum Software