Sponsored Content
Top Forums Shell Programming and Scripting grep unknown number of params Post 302560949 by GmGeubt on Sunday 2nd of October 2011 02:13:33 PM
Old 10-02-2011
the file is too big to paste here but here is an example....
some info from the file:

78 16300 Charlotte Amalie town VI 12331 4741 0000003024 0000000002 +18344032 -064933536
78 18100 Charlotte Amalie East CDP VI 2836 951 0000000467 0000000000 +18337018 -064912684
78 19000 Charlotte Amalie West CDP VI 5422 1956 0000004574 0000001576 +18339165 -064960538

what i want to do is type in the command line ./program Charlotte Amalie East CDP

the program would then output the information from that line but not the line before or after. So it has to match the parameters exactly. Thats why i thought $@ would work because its a list of the parameters given. Also note that the example given is 4 parameters long. However it can be 3 parameters long for CHarlotte Amalie town. So the number of parameters differs.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

printf returning unknown number

Hi, Can anybody tell me why this function returns 49? printf "%d\n" \'10 I don't understand what the \ and ' are there for? thanks!!! (1 Reply)
Discussion started by: m0nk3y
1 Replies

2. Shell Programming and Scripting

searching and storing unknown number of lines based on the string with a condition

Dear friends, Please help me to resolve the problem below, I have a file with following content: date of file creation : 12 feb 2007 ==================== = name : suresh = city :mumbai #this is a blank line = date : 1st Nov 2005 ==================== few lines of some text this... (7 Replies)
Discussion started by: swamymns
7 Replies

3. Shell Programming and Scripting

Creating an unknown number of arrays

I need to create arrays like this: cnt=0 { while read myline; do if ];then firstpass="${myline##<meas>}" meas="${firstpass%%</meas>}" tempmeas="${meas%%;*}" MEAS$cnt=$tempmeas print $cnt print ${MEAS'$cnt'} ... (2 Replies)
Discussion started by: ajgwin
2 Replies

4. Solaris

PING - Unknown host 127.0.0.1, Unknown host localhost - Solaris 10

Hello, I have a problem - I created a chrooted jail for one user. When I'm logged in as root, everything work fine, but when I'm logged in as a chrooted user - I have many problems: 1. When I execute the command ping, I get weird results: bash-3.00$ usr/sbin/ping localhost ... (4 Replies)
Discussion started by: Przemek
4 Replies

5. Shell Programming and Scripting

Grep to match unknown pattern

Hi there I would like to search a file for a certain pattern, but i don't know the exact pattern i need to search for. What i do know is that i need to search for the pattern that exists the most in a certain file. so if a file looksike this: summer, summer, winter, spring, summer... (4 Replies)
Discussion started by: mrchilly
4 Replies

6. Shell Programming and Scripting

Check params for number

I have 2 and three params, both I should make sure thay numbers at one single line insted of checking for each one . Example I wroote the following way.. checking for 2 and three seperately but I shud be able to do it at on statement echo $2 | egrep '^+$' >/dev/null 2>&1 if ; then echo... (2 Replies)
Discussion started by: raopatwari
2 Replies

7. Shell Programming and Scripting

Grep with unknown pattern?

Hi. I have a small problem that I haven't been able to find out of on my own. I am not much into bash scripting, however I use grep now and then when working on my code in order to locate specific objects, so I'll just state my exact problem: The code is huge, and has a function that is... (2 Replies)
Discussion started by: Morridini
2 Replies

8. Shell Programming and Scripting

awk code to ignore the first occurence unknown number of rows in a data column

Hello experts, Shown below is the 2 column sample data(there are many data columns in actual input file), Key, Data A, 1 A, 2 A, 2 A, 3 A, 1 A, 1 A, 1 I need the below output. Key, Data A, 2 A, 2 A, 3 A, 1 A, 1 A, 1 (2 Replies)
Discussion started by: ks_reddy
2 Replies

9. Shell Programming and Scripting

Grep lines for number greater than given number

Hello, I am newbie to bash scripting. Could someone help me with the following. I have log file with output as shown below **************************LOG************************* 11/20/2013 9:11:23.64 Pinging xx.xx.xx.xx with 32 bytes of data: 11/20/2013 9:11:23.64 Reply from xx.xx.xx.xx:... (4 Replies)
Discussion started by: meena_2013
4 Replies

10. Shell Programming and Scripting

Print Unknown Number of User Inputs in awk

Hello, I am new to awk and I am trying to figure out how to print an output based on user input. For example: ubuntu:~/scripts$ steps="step1, step2, step3" ubuntu:~/scripts$ echo $steps step1, step2, step3 I am playing around and I got this pattern that I want: ... (3 Replies)
Discussion started by: tattoostreet
3 Replies
Info::CDP(3pm)						User Contributed Perl Documentation					    Info::CDP(3pm)

NAME
SNMP::Info::CDP - SNMP Interface to Cisco Discovery Protocol (CDP) using SNMP AUTHOR
Max Baker SYNOPSIS
my $cdp = new SNMP::Info ( AutoSpecify => 1, Debug => 1, DestHost => 'router', Community => 'public', Version => 2 ); my $class = $cdp->class(); print " Using device sub class : $class "; $hascdp = $cdp->hasCDP() ? 'yes' : 'no'; # Print out a map of device ports with CDP neighbors: my $interfaces = $cdp->interfaces(); my $c_if = $cdp->c_if(); my $c_ip = $cdp->c_ip(); my $c_port = $cdp->c_port(); foreach my $cdp_key (keys %$c_ip){ my $iid = $c_if->{$cdp_key}; my $port = $interfaces->{$iid}; my $neighbor = $c_ip->{$cdp_key}; my $neighbor_port = $c_port->{$cdp_key}; print "Port : $port connected to $neighbor / $neighbor_port "; } DESCRIPTION
SNMP::Info::CDP is a subclass of SNMP::Info that provides an object oriented interface to CDP information through SNMP. CDP is a Layer 2 protocol that supplies topology information of devices that also speak CDP, mostly switches and routers. CDP is implemented in Cisco and some HP devices. Create or use a device subclass that inherits this class. Do not use directly. Each device implements a subset of the global and cache entries. Check the return value to see if that data is held by the device. Inherited Classes None. Required MIBs CISCO-CDP-MIB MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz GLOBAL METHODS
These are methods that return scalar values from SNMP $cdp->hasCDP() Is CDP is active in this device? Accounts for SNMP version 1 devices which may have CDP but not cdp_run() $cdp->cdp_run() Is CDP enabled on this device? Note that a lot of Cisco devices that implement CDP don't implement this value. @#%$! ("cdpGlobalRun") $cdp->cdp_interval() Interval in seconds at which CDP messages are generated. ("cdpGlobalMessageInterval") $cdp->cdp_holdtime() Time in seconds that CDP messages are kept. ("cdpGlobalHoldTime") $cdp->cdp_id() Returns CDP device ID. This is the device id broadcast via CDP to other devices, and is what is retrieved from remote devices with $cdp->id(). ("cdpGlobalDeviceId") TABLE METHODS
These are methods that return tables of information in the form of a reference to a hash. CDP CACHE ENTRIES $cdp->c_capabilities() Returns Device Functional Capabilities. Results are munged into an ascii binary string, 7 digits long, MSB. Each digit represents a bit from the table below. From <http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm#18843>: (Bit) - Description(0x40) - Provides level 1 functionality.(0x20) - The bridge or switch does not forward IGMP Report packets on non router ports.(0x10) - Sends and receives packets for at least one network layer protocol. If the device is routing the protocol, this bit should not be set.(0x08) - Performs level 2 switching. The difference between this bit and bit 0x02 is that a switch does not run the Spanning-Tree Protocol. This device is assumed to be deployed in a physical loop-free topology.(0x04) - Performs level 2 source-route bridging. A source-route bridge would set both this bit and bit 0x02.(0x02) - Performs level 2 transparent bridging.(0x01) - Performs level 3 routing for at least one network layer protocol. Thanks to Martin Lorensen "martin -at- lorensen.dk" for a pointer to this information. ("cdpCacheCapabilities") $cdp->c_domain() Returns remote VTP Management Domain as defined in "CISCO-VTP-MIB::managementDomainName" ("cdpCacheVTPMgmtDomain") $cdp->c_duplex() Returns the port duplex status from remote devices. ("cdpCacheDuplex") $cdp->c_id() Returns remote device id string ("cdpCacheDeviceId") $cdp->c_if() Returns the mapping to the SNMP Interface Table. Note that a lot devices don't implement $cdp->c_index(), So if it isn't around, we fake it. In order to map the cdp table entry back to the interfaces() entry, we truncate the last number off of it : # it exists, yay. my $c_index = $device->c_index(); return $c_index if defined $c_index; # if not, let's fake it my $c_ip = $device->c_ip(); my %c_if foreach my $key (keys %$c_ip){ $iid = $key; ## Truncate off .1 from cdp response $iid =~ s/.d+$//; $c_if{$key} = $iid; } return \%c_if; $cdp->c_index() Returns the mapping to the SNMP2 Interface table for CDP Cache Entries. Most devices don't implement this, so you probably want to use $cdp->c_if() instead. See c_if() entry. ("cdpCacheIfIndex") $cdp->c_ip() If $cdp->c_proto() is supported, returns remote IPV4 address only. Otherwise it will return all addresses. ("cdpCacheAddress") $cdp->c_addr() Returns remote address ("cdpCacheAddress") $cdp->c_platform() Returns remote platform id ("cdpCachePlatform") $cdp->c_port() Returns remote port ID ("cdpDevicePort") $cdp->c_proto() Returns remote address type received. Usually IP. ("cdpCacheAddressType") $cdp->c_ver() Returns remote hardware version ("cdpCacheVersion") $cdp->c_vlan() Returns the remote interface native VLAN. ("cdpCacheNativeVLAN") $cdp->c_power() Returns the amount of power consumed by remote device in milliwatts munged for decimal placement. ("cdpCachePowerConsumption") Data Munging Callback Subroutines $cdp->munge_power() Inserts a decimal at the proper location. perl v5.12.4 2011-09-28 Info::CDP(3pm)
All times are GMT -4. The time now is 02:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy