Sorry for my mistake.my env is uclinux and the net-snmp is 5.0.9 v.I use 
enseirb.c form net-snmp homepage.And add popen().
 
 
netsnmp_register_instance(netsnmp_create_handler_registration
                              ("led2",
                               do_led2, led2_oid, OID_LENGTH(led2_oid), 
HANDLER_CAN_RWRITE));
 
 
int
do_led2(netsnmp_mib_handler *handler,
        netsnmp_handler_registration *reginfo,
        netsnmp_agent_request_info *reqinfo,
        netsnmp_request_info *requests)
{
 char tmp;
    /*
     * We are never called for a GETNEXT if it's registered as a
     * "instance", as it's "magically" handled for us. 
     */
    /*
     * a instance handler also only hands us one request at a time, so
     * we don't need to loop over a list of requests; we'll only get one.
     */
    switch (reqinfo->mode) {
    case MODE_GET:
// system("ping -c 3 192.168.0.1");
  MYDEBUG( printf("popen haha (%s  %d\n) ... ", __FILE__,__LINE__));
        snmp_set_var_typed_value(requests->requestvb,
     ASN_INTEGER,
                                 (u_char *) &led2,
     sizeof(led2));
        DEBUGMSGTL(("enseirb", "led2 current value :  %d\n", led2));
        break;
        /*
         * SET REQUEST
         *
         * multiple states in the transaction.  See:
         *http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg
         */
    case MODE_SET_RESERVE1:
        break;
    case MODE_SET_RESERVE2:
        break;
    case MODE_SET_FREE:
        /*
         * XXX: free resources allocated in RESERVE1 and/or
         * RESERVE2.  Something failed somewhere, and the states
         * below won't be called.
         */
        break;
    case MODE_SET_ACTION:
        /*
         * XXX: perform the value change here
         */
// lpdata = inb(lp_base);
 led2 = *(requests->requestvb->val.integer);
 MYDEBUG( printf("run here (%s  %d\n) ... ", __FILE__,__LINE__));
  if(led2==20) popen("ping -c 6www.google.com","r");
        break;
    case MODE_SET_COMMIT:
        /*
         * XXX: delete temporary storage
         */
        break;
    case MODE_SET_UNDO:
        /*
         * XXX: UNDO and return to previous value for the object
         */
        break;
    default:
        /*
         * we should never get here, so this is a really bad error
         */
        return SNMP_ERR_GENERR;
    }
    return SNMP_ERR_NOERROR;
}
 
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to