If you were running Windows NT, 2000, XP or 2003, you could use Win32::EventLog.

use Win32::EventLog; $Win32::EventLog::GetMessageText = 1; my $eventlog = Win32::EventLog->new('System', $ENV{ComputerName}) or d +ie "Can't open System EventLog\n"; my %event; while ($eventlog->Read(EVENTLOG_BACKWARDS_READ| EVENTLOG_SEQUENTIAL_RE +AD, 0, \%event)) { if ( $event{EventType} == EVENTLOG_INFORMATION_TYPE && $event{Source +} eq 'Tcpip' ) { print $event{RecordNumber}, ' ', scalar localtime($event{TimeGener +ated}), ' ', $event{Message}, "\n"; last; # this example only shows the last } }

I unplugged my network cable and ran it. X:\Code>eventlog.pl 4368 Wed Feb 2 21:11:23 2005 The system detected that network adapter \DEVICE\T CPIP_{FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF} was disconnected from the network, and the adapter's network configuration has been released. If the network adapter was not disconnected, this may indicate that it has malfunctioned. Please contact your vendor for updated drivers.

I plugged my network cable back in and ran it again. X:\Code>eventlog.pl 4369 Wed Feb 2 21:11:38 2005 The system detected that network adapter \DEVICE\T CPIP_{FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF} was connected to the network, and has initiated normal operation over the network adapter.

See also: Roth Consulting's EventLog.pl script.


In reply to Re: checking internet connection by Mr. Muskrat
in thread checking internet connection by sulfericacid

Title:
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, details, 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, summary, 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.