summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsource3/script/findsmb.in60
1 files changed, 31 insertions, 29 deletions
diff --git a/source3/script/findsmb.in b/source3/script/findsmb.in
index 6276bd3f39..5a8e86d722 100755
--- a/source3/script/findsmb.in
+++ b/source3/script/findsmb.in
@@ -44,7 +44,7 @@ sub ipsort # do numeric sort on last field of IP address
# look for all machines that respond to a name lookup
-open(NMBLOOKUP,"$SAMBABIN/nmblookup $BCAST '*'|") ||
+open(NMBLOOKUP,"$SAMBABIN/nmblookup $BCAST '*' --debuglevel=0|") ||
die("Can't run nmblookup '*'.\n");
# get rid of all lines that are not a response IP address,
@@ -63,7 +63,7 @@ foreach $ip (@ipaddrs) # loop through each IP address found
# find the netbios names registered by each machine
- open(NMBLOOKUP,"$SAMBABIN/nmblookup $R_OPTION -A $ip|") ||
+ open(NMBLOOKUP,"$SAMBABIN/nmblookup $R_OPTION -A $ip --debuglevel=0|") ||
die("Can't get nmb name list.\n");
@nmblookup = <NMBLOOKUP>;
close NMBLOOKUP;
@@ -89,35 +89,37 @@ foreach $ip (@ipaddrs) # loop through each IP address found
# do an smbclient command on the netbios name.
- open(SMB,"$SAMBABIN/smbclient -N -L $name -I $ip -U% |") ||
- die("Can't do smbclient command.\n");
- @smb = <SMB>;
- close SMB;
+ if ( "$name" ) {
+ open(SMB,"$SAMBABIN/smbclient -L $name -I $ip -N --debuglevel=1 2>&1 |") ||
+ die("Can't do smbclient command.\n");
+ @smb = <SMB>;
+ close SMB;
- if ($DEBUG) { # if -d flag print results of nmblookup and smbclient
- print "===============================================================\n";
- print @nmblookup;
- print @smb;
- }
-
-# look for the OS= string
-
- @info = grep(/OS=/,@smb);
- $_ = @info[0];
- if ($_) { # we found response
- s/Domain=|OS=|Server=|\n//g; # strip out descriptions to make line shorter
-
- } else { # no OS= string in response (WIN95 client)
+ if ($DEBUG) { # if -d flag print results of nmblookup and smbclient
+ print "===============================================================\n";
+ #print @nmblookup;
+ print @smb;
+ }
-# for WIN95 clients get workgroup name from nmblookup response
- @name = grep(/<00> - <GROUP>/,@nmblookup);
- $_ = @name[0];
- if ($_) {
-# Same as before for space and characters
- /(.{1,15})\s+<00>\s+/;
- $_ = "[$1]";
- } else {
- $_ = "Unknown Workgroup";
+ # look for the OS= string
+
+ @info = grep(/OS=/,@smb);
+ $_ = @info[0];
+ if ($_) { # we found response
+ s/Domain=|OS=|Server=|\n//g; # strip out descriptions to make line shorter
+
+ } else { # no OS= string in response (WIN95 client)
+
+ # for WIN95 clients get workgroup name from nmblookup response
+ @name = grep(/<00> - <GROUP>/,@nmblookup);
+ $_ = @name[0];
+ if ($_) {
+ # Same as before for space and characters
+ /(.{1,15})\s+<00>\s+/;
+ $_ = "[$1]";
+ } else {
+ $_ = "Unknown Workgroup";
+ }
}
}