Sponsored Content
Top Forums Shell Programming and Scripting Perl parsing compared to Ksh parsing Post 302222435 by popeye on Wednesday 6th of August 2008 10:07:06 PM
Old 08-06-2008
Perl parsing compared to Ksh parsing

#! /usr/local/bin/perl -w
$ip = "$ARGV[0]";
$rw = "$ARGV[1]";
$snmpg = "/usr/local/bin/snmpbulkget -v2c -Cn1 -Cn2 -Os -c $rw";
$snmpw = "/usr/local/bin/snmpwalk -Os -c $rw";
$syst=`$snmpg $ip system sysName sysObjectID`;

sysDescr.0 = STRING: Cisco Internetwork Operating System Software
IOS (tm) 7200 Software (C7200-JK9O3S-M), Version 12.3(22), RELEASE SOFTWARE (fc2)
Technical Support: Cisco - Shortcut
Copyright (c) 1986-2007 by cisco Systems, Inc.
Compiled Wed 24-Jan-07 2
sysObjectID.0 = OID: enterprises.9.1.222
sysUpTime.0 = Timeticks: (122783188) 14 days, 5:03:51.88
sysContact.0 = STRING: 1265108
sysName.0 = STRING: nameoftherouter
sysLocation.0 = STRING: someplace, ny
sysServices.0 = INTEGER: 78
sysORLastChange.0 = Timeticks: (0) 0:00:00.00
ifNumber.0 = INTEGER: 10
ifIndex.1 = INTEGER: 1
ifIndex.2 = INTEGER: 2


In ksh to get the Version number and hostname I would do something like

vers=`echo "$syst" | grep -i version | sed 's/.*ersion //' | cut -d"," -f1`
hnam=`echo "$syst" | grep sysName | head -1 | sed 's/.*RING: //' | cut -d"."
-f1`

what is perls equivalent ?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

HTML parsing by PERL

i have a HTML report file..its in attachment(a part of the whole report is attached..name "input html.doc").also its source is attached in "report source code.txt" i just want to seperate the datas like in first line it should be.. NHTEST-3848498958-NHTEST-10.2-no-baloo a and so on for whole... (3 Replies)
Discussion started by: avik1983
3 Replies

2. Shell Programming and Scripting

Parsing and getting data from XML file using ksh script

Hi All, I have a xml file for example as described below <xml> <address> <street><street> <address/> <isbn>426728783932020308393930303</isbn> <book> <name> </name> </book> . . . </xml> My problem is to get the isbn number from the above described file using ksh script. Could... (6 Replies)
Discussion started by: vinna
6 Replies

3. Shell Programming and Scripting

Parsing of file for Report Generation (String parsing and splitting)

Hey guys, I have this file generated by me... i want to create some HTML output from it. The problem is that i am really confused about how do I go about reading the file. The file is in the following format: TID1 Name1 ATime=xx AResult=yyy AExpected=yyy BTime=xx BResult=yyy... (8 Replies)
Discussion started by: umar.shaikh
8 Replies

4. Shell Programming and Scripting

Perl Parsing Argument

i wanna passing an argument which read in a file or a set of files if the files are given in the command line, otherwise use STDIN if no file argument. i got something like that, but it is not really working. so can anyone help me? which one is better to use for and how? Use perl. Thank you ... (0 Replies)
Discussion started by: mingming88
0 Replies

5. Shell Programming and Scripting

help with ksh parsing traceroute output

Good day. I am doing an enq -WA (AIX), to get a list of the print queues, I then compare that to the /etc/hosts file to 'match' the IP address associated with the print queues. What I want to do is to run a traceroute with up to 5 hops, and perform an output to a file with some "specific items".... (0 Replies)
Discussion started by: smurphy_it
0 Replies

6. Shell Programming and Scripting

Need help parsing config file in ksh

Hi all, I've done some searching here but haven't found exactly what I'm looking for so I thought I'd post up and see if someone can help out. I'm working on a shell script that I would like to store environment variables in an external file. I'm familiar with sourcing a file with variables in... (1 Reply)
Discussion started by: kungfusnwbrdr
1 Replies

7. Shell Programming and Scripting

XML parsing in KSH

Hi All, Although I was able to find past XML parsing questions, as the questions were a little different than this, I had a pretty hard time adapting those answers to this scenario. -> May I ask if anyone knows how to extract the IP addresses of the below "servers.xml" file into an array... (5 Replies)
Discussion started by: chatguy
5 Replies

8. UNIX for Advanced & Expert Users

Perl parsing help required.

Hello, I got a file like this. 5201 5202 5203 5204 1234 2345 3456 4567 6210 6220 6230 6240 The required output should be 5201 1234 6210 (9 Replies)
Discussion started by: suverman
9 Replies

9. Shell Programming and Scripting

Parsing ksh script

Is there any tool that can parsing ksh script into grammar format? e.g. the tool can parse the following ksh script: echo "hello"> abc.txt cp /home/user/abc/.profile /home/user/abc/myprofile into GENERATE abc.txt COPY /home/user/abc/.profile TO /home/user/abc/myprofile My server OS... (2 Replies)
Discussion started by: cstsang
2 Replies

10. Shell Programming and Scripting

ksh parsing arguments in a string rather than from the cmdln

Hi. I have a piece of code that reads and parses command line options. I'd like to alter it slightly to read from a string (that's set elsewhere in the script) rather than directly from the command line (arg). Can somebody show me how to do this? Many thanks. My code is as follows: typeset... (6 Replies)
Discussion started by: user052009
6 Replies
SNMPBULKWALK(1) 						     Net-SNMP							   SNMPBULKWALK(1)

NAME
snmpbulkwalk - retrieve a subtree of management values using SNMP GETBULK requests SYNOPSIS
snmpbulkwalk [APPLICATION OPTIONS] [COMMON OPTIONS] AGENT [OID] DESCRIPTION
snmpbulkwalk is an SNMP application that uses SNMP GETBULK requests to query a network entity efficiently for a tree of information. An object identifier (OID) may be given on the command line. This OID specifies which portion of the object identifier space will be searched using GETBULK requests. All variables in the subtree below the given OID are queried and their values presented to the user. Each variable name is given in the format specified in variables(5). If no OID argument is present, snmpbulkwalk will search MIB-2. If the network entity has an error processing the request packet, an error packet will be returned and a message will be shown, helping to pinpoint why the request was malformed. If the tree search causes attempts to search beyond the end of the MIB, the message "End of MIB" will be displayed. OPTIONS
-Cc Do not check whether the returned OIDs are increasing. Some agents (LaserJets are an example) return OIDs out of order, but can complete the walk anyway. Other agents return OIDs that are out of order and can cause snmpbulkwalk to loop indefinitely. By default, snmpbulkwalk tries to detect this behavior and warns you when it hits an agent acting illegally. Use -Cc to turn off this behaviour. -Ci Include the given OID in the search range. Normally snmpbulkwalk uses GETBULK requests starting with the OID you specified and returns all results in the MIB tree after that OID. Sometimes, you may wish to include the OID specified on the command line in the printed results if it is a valid OID in the tree itself. This option lets you do this. -Cn<NUM> Set the non-repeaters field in the GETBULK PDUs. This specifies the number of supplied variables that should not be iterated over. The default is 0. -Cp Upon completion of the walk, print the number of variables found. -Cr<NUM> Set the max-repetitions field in the GETBULK PDUs. This specifies the maximum number of iterations over the repeating variables. The default is 10. In addition to these options, snmpbulkwalk takes the common options described in the snmpcmd(1) manual page. Note that snmpbulkget REQUIRES an argument specifying the agent to query and at most one OID argument, as described above. EXAMPLE
The command: snmpbulkwalk -v2c -Os -c public zeus system will retrieve all of the variables under system: sysDescr.0 = STRING: "SunOS zeus.net.cmu.edu 4.1.3_U1 1 sun4m" sysObjectID.0 = OID: enterprises.hp.nm.hpsystem.10.1.1 sysUpTime.0 = Timeticks: (155274552) 17 days, 23:19:05 sysContact.0 = STRING: "" sysName.0 = STRING: "zeus.net.cmu.edu" sysLocation.0 = STRING: "" sysServices.0 = INTEGER: 72 In contrast to snmpwalk, this information will typically be gathered in a single transaction with the agent, rather than one transaction per variable found. snmpbulkwalk is thus more efficient in terms of network utilisation, which may be especially important when retrieving large tables. NOTE
As the name implies, snmpbulkwalk utilizes the SNMP GETBULK message, which is not available in SNMP v1. SEE ALSO
snmpcmd(1), variables(5). V5.6.2.1 01 May 2002 SNMPBULKWALK(1)
All times are GMT -4. The time now is 07:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy