i have a problem...

within my python script which does an snmpwalk, there should be an intelligence to create a static table which maps OIDs to corresponding text strings, query the table and in the output of snmpwalk, i need to replace the numeric string with its textual string..

for example

I want

:enterprises.18489.1.2.1.5.1.10.0 = INTEGER: 1
to be replaced with ...........XXXXX=INTEGER:1

any suggestions?

i have a problem...

within my python script which does an snmpwalk, there should be an intelligence to create a static table which maps OIDs to corresponding text strings, query the table and in the output of snmpwalk, i need to replace the numeric string with its textual string..

for example

I want

:enterprises.18489.1.2.1.5.1.10.0 = INTEGER: 1
to be replaced with ...........XXXXX=INTEGER:1

any suggestions?

am not at all finding any way of creating tables in python...:( anyone out there pls throw some light on it

Python has several kinds of data structures, including lists, tuples, sets, and dictionaries. A dictionary associates unique keys with values and is good for retrieving the value stored for any specific key.

>>> lights = {'red': 'stop', 'green': 'go', 'yellow': 'go like hell'}
>>> print 'red means ' + lights['red']
red means stop
data.replace(':enterprises.18489.1.2.1.5.1.10.0 = INTEGER: 1','...........XXXXX=INTEGER:1')

Split on the "=" and the first "." or parse the string and pick out the digits.

s = ":enterprises.18489.1.2.1.5.1.10.0 = INTEGER: 1"
t = s.split("=")
v = t[0].split(".")
to_replace=".".join(v[1:])
print to_replace
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.