Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
#! /usr/local/bin/perl eval '(exit $?0)' && eval 'exec /usr/local/bin/perl $0 ${1+"$@"}' && eval 'exec /usr/local/bin/perl $0 $argv:q' if 0; #==================================================================== # # QUERY MAC ADDRESSES FROM 3COM SWITCH # # The following program automatically gets a list of MAC # addresses on a 3com switch and which port each address # is on using Ethernet MIB:dot1dTpFdbTable. # # NOTE: Portions of this code used from David M. Town <dtown@cpan. +org> # # #==================================================================== use strict; use Net::SNMP qw(snmp_dispatcher oid_lex_sort); #=== Setup session to remote host === my ($session, $error) = Net::SNMP->session( -hostname => $ARGV[0] || 'localhost', -community => $ARGV[1] || 'public', -port => $ARGV[2] || 161 ); #===================================== #=== Was the session created? === if (!defined($session)) { printf("ERROR: %s\n", $error); exit 1; } #================================== #=== OIDs queried to retrieve information ==== my $TpFdbAddress = ''; my $TpFdbPort = ''; #============================================= #=== Print the returned MAC addresses === printf("\n== MAC Addresses: %s ==\n\n", $TpFdbAddress); my $result; if (defined($result = $session->get_table(-baseoid => $TpFdbAddress))) + { foreach (oid_lex_sort(keys(%{$result}))) { printf("%s => %s\n", $_, $result->{$_}); } print "\n"; } else { printf("ERROR: %s\n\n", $session->error()); } #========================================== #=== Print the returned MAC ports === printf("\n== MAC Ports: %s ==\n\n", $TpFdbPort); my $result; if (defined($result = $session->get_table(-baseoid => $TpFdbPort))) { foreach (oid_lex_sort(keys(%{$result}))) { printf("%s => %s\n", $_, $result->{$_}); } print "\n"; } else { printf("ERROR: %s\n\n", $session->error()); } #============================================= #=== Close the session and exit the program === $session->close; exit 0;

In reply to Query MAC address from 3com switch (final solution) by jankovig

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others musing on the Monastery: (2)
    As of 2018-01-21 23:32 GMT
    Find Nodes?
      Voting Booth?
      How did you see in the new year?

      Results (230 votes). Check out past polls.