Sorry for taking so long to get back to you on your code. My job got the best of me yesterday and I didn't get home until 1AM. But, without further ado, here's the updated code.
use strict; use Win32::NetAdmin; use Win32::Registry; #Yes, I know it's obsolete, but it's so darn cool +! #This is part of the original code... No need to edit this part. open (OUT,">list.txt") || die "Cannot create machine list. :$!"; # This will get the list of machine names from the PDC my @users; Win32::NetAdmin::GetUsers("\\\\Weasel",'',\@users); my @computers = grep { /\$$/ } @users; foreach my $box (@computers) { chop $box; # removes terminal char, must be $ from grep print OUT "$box\n"; # print each $box on a newline } close OUT; #This is the get-ip routine using Win32::Registry #(included in libwin32, so you shouldn't have any problems with instal +ling it). #The logic is: If you can connect to machine remotely, and snag it's i +p, #it's alive and running. In other words, it's a different kind of "pin +g" print "What file do you want to read?"; chomp($InFile = <STDIN>); open(IN,$InFile) || die "Cannot open $InFile: $!"; open(OUT,">results.txt") || die "Cannot create results.txt: $!"; while (<IN>) { chomp; my $remote_obj; my $host = $_; #We need a copy of $_ to log the hostname $main::HKEY_LOCAL_MACHINE->Connect($_, $remote_obj); #Hardwired in +to main:: namespace my $ip_obj; $remote_obj->Open('SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Par +ameters\\Interfaces' , $ip_obj) || print "open key failed\n"; my $regkeys = []; $ip_obj->GetKeys($regkeys); foreach (@$regkeys) { my $temp_obj; my $ip; $ip_obj->Open( "$_", $temp_obj); $temp_obj->QueryValueEx( 'IPAddress' , REG_MULTI_SZ, $ip ); $ip =~ s/^\s//; #Strip out leading whitespace (if at all) $ip =~ s/\s$//; #Strip out trailing whitespace (if at all) print OUT "$ip\t$host\n" if ( not ($ip =~ /^[0]/) ); } } close(IN); close(OUT);
This goes to show you one of the perks of working on a Win32 system: everything is in the registry if you look hard enough. I tested the code to work under strict, so everyone is happy. Not only that, but I combined finding out the ip and the ping into one step with the registry calls. I've only tested it with one computer, but it should work for you without much tweaking (if at all).

Theodore Charles III
Network Administrator
Los Angeles Senior High
4650 W. Olympic Blvd.
Los Angeles, CA 90019
323-937-3210 ext. 224
email->secon_kun@hotmail.com

In reply to Re: cleanest/most efficient way to do this by Necos
in thread cleanest/most efficient way to do this by RayRay459

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.