Käynnissä

Bash/perl script

Hello,

I need a bash or perl script that is able to take an output similar to (number of lines should be unlimited):

router-A# sh run | i "^router ospf"

router ospf 1

router-B# sh run | i "^router ospf"

router ospf 1

router-C# sh run | i "^router ospf"

router ospf 1

router-D# sh run | i "^router ospf"

router ospf 1

router-E# sh run | i "^router ospf"

router ospf 1

router-F# sh run | i "^router ospf"

router ospf 2323

router-X# sh run | i "^router ospf"

router ospf 2323

router-Z# sh run | i "^router ospf"

router ospf 2323

router-Y# sh run | i "^router ospf"

router ospf 2222

router ospf 3333

router ospf 4444

router-ZXY# sh run | i "^router ospf"

router ospf 2222

router ospf 3333

router ospf 4444

And generate three files for every set (set = routers with the identical router ospf lines, for example in the sample output routers A to E are identical)

Example based on previous output for one set (in this case the one including router-Y and router-ZXY):

file called device-set-n (this should only be the device names and n should be a number i.e. device-set-1):

router-Y

router-ZXY

file called apply-set-n (i.e. apply-set-1):

configure;router ospf 2222;ip ospf event-history lsa size large;ip ospf event-history flooding size large;ip ospf event-history event size large;ip ospf event-history adjacency size large;ip ospf event-history cli size large;router ospf 3333;ip ospf event-history lsa size large;ip ospf event-history flooding size large;ip ospf event-history event size large;ip ospf event-history adjacency size large;ip ospf event-history cli size large;router ospf 4444;ip ospf event-history lsa size large;ip ospf event-history flooding size large;ip ospf event-history event size large;ip ospf event-history adjacency size large;ip ospf event-history cli size large;end;cop run st

file called rollback-set-n (i.e. rollback-set-1):

configure;router ospf 2222; no ip ospf event-history lsa size large;no ip ospf event-history flooding size large;no ip ospf event-history event size large;no ip ospf event-history adjacency size large;no ip ospf event-history cli size large;router ospf 3333;no ip ospf event-history lsa size large;no ip ospf event-history flooding size large;no ip ospf event-history event size large;no ip ospf event-history adjacency size large;no ip ospf event-history cli size large;router ospf 4444;no ip ospf event-history lsa size large;no ip ospf event-history flooding size large;no ip ospf event-history event size large;no ip ospf event-history adjacency size large;no ip ospf event-history cli size large;end;cop run st

Thanks,

JL

Taidot: Linux, Perl, Shell Script, tietojärjestelmäarkkitehtuuri

Näytä lisää: bash router, bash flooding script, bash file, bash 0, router configure, perl linux, ospf, linux bash script, cop, cli, bash script, script event, sample perl, linux perl bash, perl sample, perl script file, run script router, linux script router, perl output, bash script perl loop, linux perl script, rollback, script bash, merlinx2040, sample perl case script

About the Employer:
( 3 reviews ) Madrid, United States

Projektin tunnus: #4231337