Dec-28-2017, 08:20 AM
as I said line will have new lien - '\n' at the end and you need to strip it.
#!/usr/bin/python # load easysnmp module from easysnmp import Session #Community for the device community ='public' #sysDescr OID oid ='SNMPv2-MIB::sysDescr.0' with open('DSLAMIP.txt') as ipfile: for sr_no, line in enumerate(ipfile, start=1): ip = line.strip() try: session = Session(hostname=ip, community=community, version=2) snmp_get = session.get(oid) result = snmp_get.value.encode('ascii') if 'IES1248-51' in result: model = 'ZyXEL' elif 'ECI' in result: model = 'ECI' elif 'IP' in result: model = 'UT' print('{} {} {}'.format(sr_no, ip, model)) except Exception as excp: print('Something went wrong!') print(excp)