r3230: swat/lang/*/include/*html are no installed anymore
[ira/wip.git] / packaging / SGI / findsmb
index 82aeb28dab31d96f223a83e7f72ec8e3981b3a78..336ff07c16f3295da6371bf8ac50a81a02f6c014 100755 (executable)
@@ -63,11 +63,19 @@ foreach $ip (@ipaddrs)              # loop through each IP address found
 
 # 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.
 
@@ -87,7 +95,7 @@ foreach $ip (@ipaddrs)                # loop through each IP address found
     @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)
 
@@ -95,7 +103,7 @@ foreach $ip (@ipaddrs)               # loop through each IP address found
       @name = grep(/<00> - <GROUP>/,@nmblookup);
       $_ = @name[0];
       if ($_) {
-        /(\S+)/;
+        /(.{1,15})\s+<00>\s+/;
         $_ = "[$1]";
       } else {
        $_ = "Unknown Workgroup";