2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-07-01 18:35:36 +00:00

check if there is nmap or not

This commit is contained in:
amy0701
2015-05-12 04:31:59 -04:00
parent 8e5ddbd556
commit 2107c99f2a

View File

@ -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 = {};