Sorry been away for a week. Ok, heres what Im doing:
There are several command outputs from routers and switches that have different information that is useful when looking to redesign. These are not log files. The format is all over the board between files. Ive been parsing through these files individually, extracting the data that I find valuable, formatting it for CSV.
I start with one file, parse through, create a file, then use one of the fields like a key field (VLAN or interface). When I make a match (depending on which field I am keying on, I add the correlating information to the end of the file in CSV format that I can import into a spreadsheet for quick reference).
As Ive been going through the files, when I match on one key word or another, if they keyword isnt present in the show file then it is throwing off the rest of the "complete file"
Im not trying to be cryptic or dodgy with my answers, I find that at times I am not great at explaining myself.
Here is an output example pulled from a spreadsheet: (first line had matches in all fields, second was missing a match which through all results to the left / incorrect fields in the output)
Is there a way for grep to output only the found string and not the whole line?
I have a ksh script which reads in a file and loops through every line looking up on a grep -f list. For it to only display only the string found i pass this to awk as a variable and loop through the list file using... (5 Replies)
In my script I read a input file and search all the files in a directory and it's sub-directories for that string using:
find . -type f -print | xargs grep $var1
This just displays all the lines the string was found on. Too much data.
What I need is to store in a file one time those... (17 Replies)
CPAN.pm: Going to build G/GA/GAAS/Unicode-String-2.09.tar.gz
Checking if your kit is complete...
Looks good
Writing Makefile for Unicode::String
cp String.pm blib/lib/Unicode/String.pm
cp lib/Unicode/CharName.pm blib/lib/Unicode/CharName.pm
/usr/bin/perl /usr/perl5/5.8.4/lib/ExtUtils/xsubpp... (5 Replies)
finding a string with another string is found
EX:
abs c/-
i want to find /-, then copy abs. i know it's easy use awk, but my problem is the substr syntax.
substr($2,2,2) will give me /-
but the conflict is /- is not always the second characted of the second string. (11 Replies)
Hi all,
I have a question..
Here is my requirement..I have 500 files in a path say /a/b/c
I have some numbers in a file which are comma seperated...and I wanted to check if the numbers are present in the FileName in the path /a/b/c..if the number is there in the file that is fine..but if... (1 Reply)
Hello Everyone,
I just started scripting this week. I have no background in programming or scripting.
I'm working on a script to grep for a variable in a log file
Heres what the log file looks like. The x's are all random clutter
xxxxxxxxxxxxxxxxxxxxx START: xxxxxxxxxxxx... (7 Replies)
Hi,
I have two variables x and y.
i need to find a particular string in a file, a workflow name and then insert the values of x and y into the next lines of the workflow name.
basically it is like as below
wf_xxxxxx
$$a=
$$b=
$$c= figo
$$d=bentley
i need to grep the 'wf_xxxx' and then... (6 Replies)
Right now, my code is:
s/Secondary Ins./Secondary Ins.\
1/g
It's adding a 1 as soon as it finds Secondary Ins.
Primary Ins.: MEDICARE B DMERC Secondary Ins.
1: CONTINENTAL LIFE INS
What I really want to achieve is having a 1 added on the next line that contain "Secondary Ins." It... (4 Replies)
hello,
I have problem with writing/adjusting a shell script.
I searched forum and unfortunately couldn't write scipt based on the information I found.
I never wtire such so it's hard for me and I do need to modify one script immediately.
case looks like:
1. 'file' that needs to be modified... (3 Replies)
i want to search a log for a string. when that string is found, i want to grab the a set number of lines that came before the string, and a set number of lines that come after the string.
so if i search for the word "Error" in the /var/log/messages file, how can I output the 20 lines that came... (4 Replies)
Discussion started by: SkySmart
4 Replies
LEARN ABOUT DEBIAN
snmp::info::layer2::c1900
Info::Layer2::C1900(3pm) User Contributed Perl Documentation Info::Layer2::C1900(3pm)NAME
SNMP::Info::Layer2::C1900 - SNMP Interface to data from Cisco Catalyst 1900 Network Switches running CatOS
AUTHOR
Max Baker
SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $c1900 = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 1
)
or die "Can't connect to DestHost.
";
my $class = $c1900->class();
print "SNMP::Info determined this device to fall under subclass : $class
";
DESCRIPTION
Provides abstraction to the configuration information obtainable from a Catalyst 1900 device through SNMP. See SNMP::Info for full
documentation
Note that most of these devices only talk SNMP version 1, but not all.
For speed or debugging purposes you can call the subclass directly, but not after determining a more specific class using the method above.
my $c1900 = new SNMP::Info::Layer2::C1900(...);
Inherited classes
SNMP::Info::CDP
SNMP::Info::CiscoStats
SNMP::Info::CiscoConfig
SNMP::Info::Layer2
Required MIBs
STAND-ALONE-ETHERNET-SWITCH-MIB (ESSWITCH-MIB)
ESSWITCH-MIB is included in the Version 1 MIBs from Cisco.
They can be found at ftp://ftp.cisco.com/pub/mibs/v1/v1.tar.gz
Inherited MIBs
See "Required MIBs" in SNMP::Info::CDP for its MIB requirements.
See "Required MIBs" in SNMP::Info::CiscoStats for its MIB requirements.
See "Required MIBs" in SNMP::Info::CiscoConfig for its MIB requirements.
See "Required MIBs" in SNMP::Info::Layer2 for its MIB requirements.
GLOBALS
These are methods that return scalar value from SNMP
$c1900->c1900_flash_status()
Usually contains the version of the software loaded in flash. Used by os_ver()
"STAND-ALONE-ETHERNET-SWITCH-MIB::upgradeFlashBankStatus"
$c1900->os()
Returns 'catalyst'
$c1900->os_ver()
Returns CatOS version if obtainable. First tries to use SNMP::Info::CiscoStats->os_ver() . If that fails then it checks for the
presence of $c1900->c1900_flash_status() and culls the version from there.
$c1900->vendor()
Returns 'cisco' :)
Overrides
$c1900->cisco_comm_indexing()
Returns 1. Use vlan indexing.
$c1900->bulkwalk_no
Return 1. Bulkwalk is turned off for this class.
Globals imported from SNMP::Info::CDP
See "GLOBALS" in SNMP::Info::CDP for details.
Globals imported from SNMP::Info::CiscoStats
See "GLOBALS" in SNMP::Info::CiscoStats for details.
Globals imported from SNMP::Info::CiscoConfig
See "GLOBALS" in SNMP::Info::CiscoConfig for details.
Globals imported from SNMP::Info::Layer2
See "GLOBALS" in SNMP::Info::Layer2 for details.
TABLE METHODS
These are methods that return tables of information in the form of a reference to a hash.
Overrides
$c1900->interfaces()
Returns reference to the map between IID and physical Port.
$c1900->i_duplex()
Returns reference to map of IIDs to current link duplex
$c1900->i_duplex_admin()
Returns reference to hash of IIDs to admin duplex setting
$c1900->i_name()
Crosses "ifName" with $c1900->c1900_p_name() and returns the human set port name if exists.
$c1900->i_vlan()
Returns a mapping between the interface and the VLAN / bridge group if overlap is not enabled.
$c1900->i_vlan_membership()
Returns reference to hash of arrays: key = interface, value = array of VLAN / bridge group IDs.
Example:
my $interfaces = $c1900->interfaces();
my $vlans = $c1900->i_vlan_membership();
foreach my $iid (sort keys %$interfaces) {
my $port = $interfaces->{$iid};
my $vlan = join(',', sort(@{$vlans->{$iid}}));
print "Port: $port VLAN: $vlan
";
}
$c1900->bp_index()
Returns a bp_index that contains the original bp_index entries and extra entries for those interfaces listed in if_index, as some C1900
devices do not return complete bp_indexes.
STAND-ALONE-ETHERNET-SWITCH-MIB Switch Port Table Entries:
$c1900->c1900_p_index()
Maps the Switch Port Table to the IID
"swPortIfIndex"
$c1900->c1900_p_duplex()
Gives Port Duplex Info
("swPortDuplexStatus")
$c1900->c1900_p_duplex_admin()
Gives admin setting for Duplex Info
("swPortFullDuplex")
$c1900->c1900_p_name()
Gives human set name for port
("swPortName")
$c1900->c1900_p_up_admin()
Gives Admin status of port enabled.
("swPortAdminStatus")
$c1900->c1900_p_type()
Gives Type of port, i.e. "general-ethernet"
("swPortMediaCapability")
$c1900->c1900_p_media()
Gives the media of the port , i.e. ""fiber-sc""
("swPortConnectorType")
Table Methods imported from SNMP::Info::CDP
See "TABLE METHODS" in SNMP::Info::CDP for details.
Table Methods imported from SNMP::Info::CiscoStats
See "TABLE METHODS" in SNMP::Info::CiscoStats for details.
Table Methods imported from SNMP::Info::CiscoConfig
See "TABLE METHODS" in SNMP::Info::CiscoConfig for details.
Table Methods imported from SNMP::Info::Layer2
See "TABLE METHODS" in SNMP::Info::Layer2 for details.
SET METHODS
These are methods that provide SNMP set functionality for overridden methods or provide a simpler interface to complex set operations. See
"SETTING DATA VIA SNMP" in SNMP::Info for general information on set operations.
$c1900->set_i_duplex_admin(duplex, ifIndex)
Sets port duplex, must be supplied with duplex and port "ifIndex". Speed choices are 'auto', 'half', 'full'.
Example:
my %if_map = reverse %{$c1900->interfaces()};
$c1900->set_i_duplex_admin('auto', $if_map{'1'})
or die "Couldn't change port duplex. ",$c1900->error(1);
perl v5.12.4 2011-09-28 Info::Layer2::C1900(3pm)