parsing output from expect script
- From: MattB <iamatt@xxxxxxxxx>
- Date: Wed, 8 Feb 2012 09:36:43 -0800 (PST)
Hello,
My goal is to use expect to
1-connect to a series of systems
2-execute a command 20 times on each node to read through a log
(command is 'readlog')
3-grab the output of the commands
4-apply an regular expression on the returned buffer to only search
for lines with "Chassis"
5-prepend a hostname to each of the parsed lines returned from #4 like
nod200-bmc : <text after ran thru regex which contains "Chassis">
Here is what I have so far . This script does login ok and runs my
command to get logs but I see everything including the telnet
password send etc. In addition I also see a bunch of log info I do
not need.
===============
#!/usr/bin/expect -f
set expect_out(buffer) {}
set userid FOO
set passwd BAR
set timeout 10
match_max 100000
set nodecount 1
while {$nodecount < 3500} {
set node_init($nodecount) 1
log_user 0
spawn telnet nod$nodecount-bmc
expect "login : "
send -- "$userid\r"
expect -exact "USERID\r
Password: "
send -- "$passwd\r"
set count 20
while {$count > 0} {
send -- "readlog\r"
set count [expr $count -1]
#regular expression go here maybe?
}
send -- "exit\r"
expect "exit\r"
incr nodecount
}
send -- "exit\r"
expect eof
===============
Thank you for any insight.
re,
MattB
.
- Follow-Ups:
- Re: parsing output from expect script
- From: F. Michael Orr
- Re: parsing output from expect script
- Prev by Date: Re: calling "c" from TCL
- Next by Date: Re: How widely used is Expect in text automationb?
- Previous by thread: question around 'exec'
- Next by thread: Re: parsing output from expect script
- Index(es):
Relevant Pages
|