Menu

#160 No error when ping scan failed

0.9
closed
nobody
None
1
2015-01-09
2014-01-16
No

ping scan is using getPHPExecutableFromPath() to know where is PHP. If this function returned FALSE, the line is executed without it, so result is always "No alive host found!".
I advise to edit site/ipaddr/scan/subnetScanDiscoveryPing.php
and add check on phpPath return code.

Code would be :

# check if any hits are present
if($ip) {
    # create 1 line for $argv
    $ip = implode(";", $ip);

    # get php exec path
    $phpPath = getPHPExecutableFromPath();
    if ($phpPath === false) $error = 'Cannot find PHP executable path.';
    else {
        # set script
        $script = dirname(__FILE__) . '/../../../functions/scan/'.$_REQUEST['pingType'].'Script.php';

        # invoke CLI with threading support
        $cmd = "$phpPath $script '$ip'";
        # save result to $output
        exec($cmd, $output, $retval);

        # format result - alive
        $alive = json_decode(trim($output[0]));

        # if not numeric means error, print it!
        if(!is_numeric($alive[0]))  {
            $error = $alive[0];
        }

        #verify that pign path is correct
        if(!file_exists($pathPing)) { $pingError = true; }
    }
}

Discussion

  • Miha Petkovsek

    Miha Petkovsek - 2014-02-21
    • status: open --> closed
     
  • Miha Petkovsek

    Miha Petkovsek - 2014-02-21

    Hi, have added pathCheck with modified ping code for next relase.

    brm

     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB