# get the first <00> name
- @name = grep(/<00>/,@nmblookup);
+ @name = grep(/<00> - /,@nmblookup);
$_ = @name[0];
- if ($_) { # we have a netbios name
- /(\S+)/;
- $name = $1;
+ if ($_) { # we have a netbios name
+ if (/GROUP/) { # is it a group name
+ ($name, $aliases, $type, $length, @addresses) =
+ gethostbyaddr(pack('C4',split('\.',$ip)),2);
+ if (! $name) { # could not get name
+ $name = "unknown nis name";
+ }
+ } else {
+ /(.{1,15})\s+<00>\s+/;
+ $name = $1;
+ }
# do an smbclient command on the netbios name.
@info = grep(/OS=/,@smb);
$_ = @info[0];
if ($_) { # we found response
- s/Domain=|OS=|Server=|\n//g; # strip out descriptions to make line shorter
+ s/.*Domain=|OS=|Server=|\n//g; # strip out descriptions to make line shorter
} else { # no OS= string in response (WIN95 client)
@name = grep(/<00> - <GROUP>/,@nmblookup);
$_ = @name[0];
if ($_) {
- /(\S+)/;
+ /(.{1,15})\s+<00>\s+/;
$_ = "[$1]";
} else {
$_ = "Unknown Workgroup";