Python Forum
something going wrong.. code is not working
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
something going wrong.. code is not working
#6
Thanks Buran,
Changes in code as below

#!/usr/bin/python
from easysnmp import Session
# load easysnmp module
community ='public'
#Community for the device
oid ='SNMPv2-MIB::sysDescr.0'
#sysDescr OID
sr_no = 0
with open('DSLAMIP.txt') as ipfile:
#    line = ipfile.readlines()
#    print line
    for line in ipfile:
#        print line
        try:
            session = Session(hostname=line, 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'
            sr_no += 1
            print sr_no+" "+line+ " " +model
        except:
            print('Connection timed out') 
easysnmp session is not working,
Output is:- Connection timed out
Connection timed out
Connection timed out
Connection timed out
Connection timed out
Connection timed out
Connection timed out
Connection timed out
Connection timed out
Connection timed out

whereas :- i am able to do this manually
[root@localhost scripts]# snmpwalk -v2c -c public 10.113.1.1 SNMPv2-MIB::sysDescr.0
SNMPv2-MIB::sysDescr.0 = STRING: ECI telecom HiFOCuS broadband access system
Reply


Messages In This Thread
RE: something going wrong.. code is not working - by anna - Dec-28-2017, 07:42 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I have a code which is very simple but still I cannot detect what's wrong with it max22 1 537 Nov-07-2023, 04:32 PM
Last Post: snippsat
  New to Python - Not sure why this code isn't working - Any help appreciated TheGreatNinx 4 1,033 Jul-22-2023, 10:21 PM
Last Post: Pedroski55
  code not working when executed from flask app ThomasDC 1 960 Jul-18-2023, 07:16 AM
Last Post: ThomasDC
  Something wrong with my code FabianPruitt 5 915 Jul-03-2023, 10:55 PM
Last Post: Pedroski55
  Compiles Python code with no error but giving out no output - what's wrong with it? pythonflea 6 1,660 Mar-27-2023, 07:38 AM
Last Post: buran
  Video recording with Raspberry Pi - What´s wrong with my python code? Montezuma1502 3 1,328 Feb-24-2023, 06:14 PM
Last Post: deanhystad
  Why doesn't this code work? What is wrong with path? Melcu54 7 1,926 Jan-29-2023, 06:24 PM
Last Post: Melcu54
  I am new to python and Could someone please explain how this below code is working? kartheekdas 2 1,062 Dec-19-2022, 05:24 PM
Last Post: kartheekdas
  Am I wrong or is Udemy wrong? String Slicing! Mavoz 3 2,698 Nov-05-2022, 11:33 AM
Last Post: Mavoz
Exclamation My code is not working as I expected and I don't know why! Marinho 4 1,135 Oct-13-2022, 08:09 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020