- my $resp = $bpc->cmdSystemOrEval($nmbCmd, undef, $args);
- if ( $resp =~ /^\s*(\d+\.\d+\.\d+\.\d+)\s+\Q$host/m ) {
- return $1;
+ foreach my $resp ( split(/[\n\r]+/, $bpc->cmdSystemOrEval($nmbCmd, undef,
+ $args) ) ) {
+ if ( $resp =~ /querying\s+\Q$host\E\s+on\s+(\d+\.\d+\.\d+\.\d+)/i ) {
+ $subnet = $1;
+ $subnet = $1 if ( $subnet =~ /^(.*?)(\.255)+$/ );
+ } elsif ( $resp =~ /^\s*(\d+\.\d+\.\d+\.\d+)\s+\Q$host/ ) {
+ my $ip = $1;
+ $firstIpAddr = $ip if ( !defined($firstIpAddr) );
+ $ipAddr = $ip if ( !defined($ipAddr) && $ip =~ /^\Q$subnet/ );
+ }
+ }
+ $ipAddr = $firstIpAddr if ( !defined($ipAddr) );
+ if ( defined($ipAddr) ) {
+ print("NetBiosHostIPFind: found IP address $ipAddr for host $host\n")
+ if ( $bpc->{verbose} );
+ return $ipAddr;