summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2003-09-05 13:07:41 +0000
committerGerald Carter <jerry@samba.org>2003-09-05 13:07:41 +0000
commit605caa4172d058c33e96ac8033fedca311a75e34 (patch)
treea02a341101691afe1fdffd29647852e0f0a2caa3 /source3
parentf0441479f4b7fdfc997a984d2343de1d094f5bd6 (diff)
downloadsamba-605caa4172d058c33e96ac8033fedca311a75e34.tar.gz
samba-605caa4172d058c33e96ac8033fedca311a75e34.tar.bz2
samba-605caa4172d058c33e96ac8033fedca311a75e34.zip
fix some problems with the findsmb script due to changes in smbclient & nmblookup
(This used to be commit 50bb063f3ba0ce0f336bd9f1af3090839ee7b118)
Diffstat (limited to 'source3')
-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";
+ }
}
}