Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Do you by any chance have a sample code for turning the port on and off from a 3com switch. Info for the port on/off part: - test switch is 142.3.247.200 - community password is public (includes write privlidges) - There is a machine plugged into port 1 of this switch with IP address 142.3.145.73.

Replies are listed 'Best First'.
Re: query a MAC address
by zengargoyle (Deacon) on Nov 30, 2003 at 00:17 UTC

    the OID is ifAdminStatus.

    $ snmptranslate -IR -Td ifAdminStatus IF-MIB::ifAdminStatus ifAdminStatus OBJECT-TYPE -- FROM IF-MIB, RFC1213-MIB SYNTAX INTEGER { up(1), down(2), testing(3) } MAX-ACCESS read-write STATUS current DESCRIPTION "The desired state of the interface. The testing(3) s +tate indicates that no operational packets can be passed. When + a managed system initializes, all interfaces start with ifAdminStatus in the down(2) state. As a result of either explicit management action or per configuration informatio +n retained by the managed system, ifAdminStatus is then changed to either the up(1) or testing(3) states (or remai +ns in the down(2) state)." ::= { iso(1) org(3) dod(6) internet(1) mgmt(2) mib-2(1) interfaces(2) +ifTable(2) ifEntry(1) 7 }

    this will turn a port off...

    $ snmpset $ARGS $HOST .1.3.6.1.2.1.2.2.1.7.$PORT i 2

    set back to '1' to turn it back on.

Re: query a MAC address
by NetWallah (Canon) on Nov 30, 2003 at 03:06 UTC
    You did not specify your OS - you could do this in Perl using an SNMP module but why ?

    The previous comment shows the *nix way.

    The Win32 (NT and above) would require snmputil from the NT resource kit. The general syntax for your SET operation would be
    snmputil set <agent-IP> <community-name> OID value