Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: How can I get which Windows domain an IP belongs to?

by idsfa (Vicar)
on Oct 13, 2003 at 21:36 UTC ( [id://298954]=note: print w/replies, xml ) Need Help??


in reply to How can I get which Windows domain an IP belongs to?

The easy way. (untested)

use Net::NBName; my $nb = Net::NBName->new; while(my $addr=<>) { chomp $addr; my $ns = $nb->node_status($addr); if ($ns) { ($dom) = grep {$_->suffix == '\0' && $_->G eq "GROUP"} $ns->names(); print "$addr ".$dom->name()."$/"; } }

The hard way (without CPAN). (tested)

while(my $addr=<>) { my $domain = "(undetermined)"; chomp $addr; open(NMB,"nbtstat -A $addr |"); while(<NMB>) { ($domain) = m/(\w+)/ if (/GROUP/ && /<1E>/); } close NMB; print "$addr $domain$/"; }

Remember, when you stare long into the abyss, you could have been home eating ice cream.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://298954]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-25 16:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found