From 605caa4172d058c33e96ac8033fedca311a75e34 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 5 Sep 2003 13:07:41 +0000 Subject: fix some problems with the findsmb script due to changes in smbclient & nmblookup (This used to be commit 50bb063f3ba0ce0f336bd9f1af3090839ee7b118) --- source3/script/findsmb.in | 60 ++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 29 deletions(-) (limited to 'source3') 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 = ; 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 = ; - 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 = ; + 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> - /,@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> - /,@nmblookup); + $_ = @name[0]; + if ($_) { + # Same as before for space and characters + /(.{1,15})\s+<00>\s+/; + $_ = "[$1]"; + } else { + $_ = "Unknown Workgroup"; + } } } -- cgit