CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
List Netbios Names

 



yellowman
Novice

Aug 21, 2006, 8:24 AM

Post #1 of 3 (218 views)
List Netbios Names Can't Post

Anyone know how to get a list of every PC running on my domain? I need the Netbios name and not the IP address. I figured I could use NBname, but I can't get it to work.

Thanks.


davorg
Thaumaturge / Moderator

Aug 22, 2006, 2:39 AM

Post #2 of 3 (213 views)
Re: [yellowman] List Netbios Names [In reply to] Can't Post

If you explained a bit more what you meant by "I can't get it to work" then perhaps someone might be able to help you solve the problems.

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks


yellowman
Novice

Aug 22, 2006, 4:49 AM

Post #3 of 3 (211 views)
Re: [davorg] List Netbios Names [In reply to] Can't Post

I am just using the sample code that came with the module so that I can play around with it and when I run what is below all that I get back is the IP addresses. It looks like the first print statement works (print "$ip ";), but the last print statement is ignored (print "$mac_address $domain\\$machine $user";). Any ideas as to why?


Code
  

use Net::NBName;
use Net::Netmask;

$mask = shift or die "expected: <subnet>\n";

$nb = Net::NBName->new;
$subnet = Net::Netmask->new2($mask);
for $ip ($subnet->enumerate) {
print "$ip ";
$ns = $nb->node_status($ip);
if ($ns) {
for my $rr ($ns->names) {
if ($rr->suffix == 0 && $rr->G eq "GROUP") {
$domain = $rr->name;
}
if ($rr->suffix == 3 && $rr->G eq "UNIQUE") {
$user = $rr->name;
}
if ($rr->suffix == 0 && $rr->G eq "UNIQUE") {
$machine = $rr->name unless $rr->name =~ /^IS~/;
}
}
$mac_address = $ns->mac_address;
print "$mac_address $domain\\$machine $user";
}
print "\n";
}


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives