Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Have expanded the variables further to fix more issues now.
#!/usr/local/bin/perl ## use strict; use warnings; use Data::Dumper; my @output = ( qq/Software\n/ .qq/ BIOS: version 3.6.0\n/ .qq/ kickstart: version 7.1(5)N1(1)\n/ .qq/ system: version 7.1(5)N1(1)\n/ .qq/ kickstart image file is: bootflash:\/\/\/n5000-uk9-kickstart +.7.1.5.N1.1.bin\n/ .qq/ system image file is: bootflash:\/\/\/n5000-uk9.7.1.5.N1. +1.bin\n/ .qq/Hardware\n/ .qq/ cisco Nexus 5548 Chassis ("O2 32X10GE\/Modular Universal Pla +tform Supervisor")\n/ .qq/ Intel(R) Xeon(R) CPU with 8253840 kB of memory.\n/ .qq/ Processor Board ID FOC163849D1\n/ .qq/ Device name: tpecasw01\n/ .qq/ bootflash: 2007040 kB\n/ .qq/Kernel uptime is 636 day(s), 1 hour(s), 34 minute(s), 49 secon +d(s)\n/ ); print "@output\n"; foreach (@output) { my %details; if (/^Hardware/mi) { $details{'Chassis'} = $1 if (/^\s*cisco Nexus (\S+) Chassi +s/mi); $details{'Main Memory'} = $1 if (/^\s*Intel.* with (\S+) kB of + memory/mi); $details{'Name'} = $1 if (/^\s*Device name: (\S+)/mi); $details{'Uptime'} = $1 if (/^\s*Kernel uptime is (.*?)\s*$/mi +); $details{'Version'} = $1 if (/^\s*system: .*version (\S+?)[,\s +]/mi); $details{'IOS File'} = $1 if (/^\s*system image file is:\s*"(. +*)"/mi); $details{Serial} = $1 if (/^\s*Processor board ID (\S+)/mi); $details{'ROM Version'} = $1 if (/^\s*BIOS: .*version (\S+?)[, +\s]/mi); # aka BIOS $details{'Boot Version'} = $1 if (/^\s*kickstart: .*version (\ +S+?)[,\s]/mi); # aka kickstarter $details{'Boot Flash'} = $1 if (/^\s*bootflash: (\S+)/mi); } print Dumper(\%details); }

All are working apart from $details('IOS File') is not populating/displaying. Any ideas? Result should be bootflash:///n5000-uk9.7.1.5.N1.1.bin

Value for 'IOS File' missing in results...

Software BIOS: version 3.6.0 kickstart: version 7.1(5)N1(1) system: version 7.1(5)N1(1) kickstart image file is: bootflash:///n5000-uk9-kickstart.7.1.5.N1.1 +.bin system image file is: bootflash:///n5000-uk9.7.1.5.N1.1.bin Hardware cisco Nexus 5548 Chassis ("O2 32X10GE/Modular Universal Platform Sup +ervisor") Intel(R) Xeon(R) CPU with 8253840 kB of memory. Processor Board ID FOC163849D1 Device name: tpecasw01 bootflash: 2007040 kB Kernel uptime is 636 day(s), 1 hour(s), 34 minute(s), 49 second(s) $VAR1 = { 'Uptime' => '636 day(s), 1 hour(s), 34 minute(s), 49 second( +s)', 'Serial' => 'FOC163849D1', 'Version' => '7.1(5)N1(1)', 'ROM Version' => '3.6.0', 'Main Memory' => '8253840', 'Name' => 'tpecasw01', 'Boot Version' => '7.1(5)N1(1)', 'Chassis' => '5548' };

In reply to Re: Parse variables from @output by Cisco_Dave
in thread Parse variables from @output by Cisco_Dave

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-23 13:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found