From 2107c99f2a28f36672330a8c50cc9c673aa89268 Mon Sep 17 00:00:00 2001 From: amy0701 Date: Tue, 12 May 2015 04:31:59 -0400 Subject: [PATCH] check if there is nmap or not --- xCAT-server/lib/xcat/plugins/bmcdiscover.pm | 23 ++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm index 88b7aa3fd..22136d279 100755 --- a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm @@ -30,6 +30,7 @@ use File::Basename; use File::Path; use Cwd; +my $nmap_path; my $debianflag = 0; my $tempstring = xCAT::Utils->osver(); @@ -155,6 +156,26 @@ sub bmcdiscovery_processargs { return 3; } + ###################################### + # check if there is nmap or not + ###################################### + if ( -x '/usr/bin/nmap' ) + { + $nmap_path="/usr/bin/nmap"; + } + elsif ( -x '/usr/local/bin/nmap' ) + { + $nmap_path="/usr/local/bin/nmap"; + } + else + { + my $rsp; + push @{ $rsp->{data} }, "\tThere is no nmap in /usr/bin/ or /usr/local/bin/. \n "; + xCAT::MsgUtils->message( "E", $rsp, $::CALLBACK ); + return 1; + + } + ######################################### # This command is for linux ######################################### @@ -227,7 +248,7 @@ sub scan_process{ # get live ip list ########################################################### if ( $method eq "nmap" ) { - my $bcmd = "/usr/bin/nmap -sn $range | grep for |cut -d ' ' -f5 |tr -s '\n' ' ' "; + my $bcmd = join(" ",$nmap_path," -sn $range | grep for |cut -d ' ' -f5 |tr -s '\n' ' ' "); $ip_list = xCAT::Utils->runcmd("$bcmd", -1); if ($::RUNCMD_RC != 0) { my $rsp = {};