parsing output from expect script



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
.



Relevant Pages

  • Re: Login session hasnt been abandoned after TIMEOUT time
    ... The login command is used at the beginning of each terminal ... session to identify oneself to the system. ... trying to kick off idle users. ...
    (comp.unix.solaris)
  • Re: pwd.db/spwd.db file corupption when having unsafe system poweroff
    ... with pw command, waited for 2minutes and then power off the system.. ... For login processes, the plain text files and the database ...
    (freebsd-questions)
  • Re: Failsafe mode
    ... > and paste or failing that copy the message down character for ... >> If I exit out and log back in as my alternate user ... user command line prompt in the upper left corner and a black blank screen. ... If I ctl alt F1 I get the system login prompt. ...
    (alt.os.linux.suse)
  • Re: security
    ... a login and config apache to read the dir in his home dir. ... command or sequence of commands. ... To unsubscribe or change subscription options: ...
    (Fedora)
  • [HPADM] SUMMARY "Users not active"
    ... Sysadm guy setup to remove old login file and keep only the current dated ... you'll have to modify the script to use alternate wtmp files. ... Now if you run the logins command you can get more info... ...
    (HP-UX-Admin)