in reply to SNMP using perl/cgi

In the first instance you want to change the error report on not being able to create the SNMP session to something like:

print ("Err Creation Session Obj: $error ");
as a) you have just determined that $session is undef so you can't call a method on it and b) the method call wouldn't be interpolated in a string anyway as you are seeing. $error here is returned by session and has a meaningful value if the session creation failed.

/J\

Replies are listed 'Best First'.
Re^2: SNMP using perl/cgi
by msk_0984 (Friar) on Aug 14, 2006 at 09:29 UTC
    Yes

    Your are right when i hav changed it to

    print ("Err Creation Session Obj: $error ");
    I get the output as

    Err Creation Session Obj: Failed to open UDP/IPv4 socket: Permission denied

    Update : But how should i overcome this prob please help me out.

    Work Hard Party Harderrr!!
    Sushil Kumar

      It's not immediately obvious what the origin of this message is from the Net::SNMP source, normally I wouldn't expect EPERM from simply try to create a UDP socket, but as you don't say what your OS is I can't be sure. You might want to get more diagnostic information by adding -debug => 0x04, to the arguments to session(). Also can you confirm whether the program works properly from the command line or not.

      /J\

      /usr/bin/perl implies some sort of Unix. You are trying to listen to port number 161. On most unices, only the root user is allowed to open ports lower than 1024. You need to be root or use a different port. (Note that running CGI programs as root is not a GoodIdea(tm).


      The intelligent reader will judge for himself. Without examining the facts fully and fairly, there is no way of knowing whether vox populi is really vox dei, or merely vox asinorum. — Cyrus H. Gordon