mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-30 05:57:08 +00:00
better support for ping under a non-root account
git-svn-id: https://svn.fhem.de/fhem/trunk@2659 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
b241d996c1
commit
5739dc4ba4
@ -30,7 +30,6 @@ package main;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Blocking;
|
use Blocking;
|
||||||
use Net::Ping;
|
|
||||||
use Time::HiRes qw(gettimeofday sleep);
|
use Time::HiRes qw(gettimeofday sleep);
|
||||||
use DevIo;
|
use DevIo;
|
||||||
|
|
||||||
@ -356,24 +355,32 @@ PRESENCE_DoLocalPingScan($$)
|
|||||||
my ($string) = @_;
|
my ($string) = @_;
|
||||||
my ($name, $device) = split("\\|", $string);
|
my ($name, $device) = split("\\|", $string);
|
||||||
|
|
||||||
my $pingtool = Net::Ping->new("icmp");
|
|
||||||
my $retcode;
|
my $retcode;
|
||||||
my $return;
|
my $return;
|
||||||
|
my $temp;
|
||||||
|
if($^O =~ m/Win/)
|
||||||
if($pingtool)
|
|
||||||
{
|
{
|
||||||
|
eval "require Net::Ping;";
|
||||||
|
my $pingtool = Net::Ping->new("syn");
|
||||||
|
|
||||||
$retcode = $pingtool->ping($device, 5);
|
if($pingtool)
|
||||||
$return = "$name|".($retcode ? "present" : "absent");
|
{
|
||||||
|
$retcode = $pingtool->ping($device, 5);
|
||||||
|
$return = "$name|".($retcode ? "present" : "absent");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$return = "$name|error|Could not create a Net::Ping object.";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$return = "$name|error|Could not create a Net::Ping object.";
|
$temp = qx(ping -c 4 $device);
|
||||||
|
$return = "$name|".($temp =~ /\d+ bytes from/ ? "present" : "absent");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user