Hello all, I'm new to shell scripting.
I wrote a Shell/Expect script to telnet into my devices and run a command debug dev -m. Below is the output of that command that shows all the cards and their serial number:
Code:
spawn telnet 192.168.1.118
Trying 192.168.1.118...
Connected to 192.168.1.118.
Escape character is '^]'.
login: admin
password:
NewYork.MON1.1M> debug dev -m
Configuration Status
Slot Model Model Version Serial Number
------------------------------------------------------------------------------
M* 1 sys-a12-std sys-a12-std v7-0-5 0B0000000F
2 atm-m11-1a1 atm-m11-1a1 v7-0-5 0B0000000F
3 tmx-m12-tnl2 tmx-m12-tnl2 v7-0-5 0B0000000F
4 enc-s11-std-d enc-s11-std-d v7-0-5 0B0000000F
NewYork.MON1.1M> spawn telnet 192.168.1.119
Trying 192.168.1.119...
Connected to 192.168.1.119.
Escape character is '^]'.
login: admin
password:
NewYork.EDGE1a.1M> debug dev -m
Configuration Status
Slot Model Model Version Serial Number
------------------------------------------------------------------------------
M* 1 sys-a12-std sys-a12-std v7-0-4 0B0000000F
3 atm-m11-1a1 atm-m11-1a1 v7-0-4 0B0000000F
8 tmx-m12-tnl2 tmx-m12-tnl2 v7-0-4 0B0000000F
I was wondering if anyone have an idea of changing the output the file to look something like this:
Code:
NewYork.EDGE1a.1M M* 1 sys-a12-std sys-a12-std v7-0-4 0B0000000F
NewYork.EDGE1a.1M 3 atm-m11-1a1 atm-m11-1a1 v7-0-4 0B0000000F
NewYork.EDGE1a.1M 8 tmx-m12-tnl2 tmx-m12-tnl2 v7-0-4 0B0000000F
Here is the expect script:
Code:
set hostname [lrange $argv 0 0]
spawn telnet $hostname
expect "login";
send "admin\n";
expect "password:";
send "password\n";
expect ">";
send "debug dev -m";
I have a few hundred of these devices all with different amount of cards in each slot.
Thanks a million for any input.
SeeFor