Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I pipe and nest commands ?

Status
Not open for further replies.

sumncguy

IS-IT--Management
Joined
May 22, 2006
Messages
118
Location
US
sysDescr.0 = STRING: Cisco IOS Software, C3560 Software (C3560-IPBASEK9-M), Version 12.2(25)SEE2, RELEASE SOFTWARE (fc1)


In KSH, to isolate "C3560" and "12.2(25)SEE2"

x=`snmpwalk -c comstring 10.11.12.13 sysDescr.0 |\
awk '{print $7" "$11 | sed 's/\,//g'`

x now = c3560 12.2(25)SEE2

Is there a perl equivalent ?

Heres what Im doing now in perl ... just looks crappy and too many lines ...

@x=`snmpwalk -c comstring 10.11.12.13 sysDescr.0`;
@x = split(/ /, @x);
push(@ver, $x[6]);
push(@ver, $x[10]);
print qq(@ver);
 
Simplifying your perl code, and not even bothering to read what you translated from:

Code:
print (map {split / /} `snmpwalk -c comstring 10.11.12.13 sysDescr.0`)[6,10];

- Miller
 

Thanks Ill give it a try.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top