mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-26 22:25:43 +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 warnings;
|
||||
use Blocking;
|
||||
use Net::Ping;
|
||||
use Time::HiRes qw(gettimeofday sleep);
|
||||
use DevIo;
|
||||
|
||||
@ -356,24 +355,32 @@ PRESENCE_DoLocalPingScan($$)
|
||||
my ($string) = @_;
|
||||
my ($name, $device) = split("\\|", $string);
|
||||
|
||||
my $pingtool = Net::Ping->new("icmp");
|
||||
my $retcode;
|
||||
my $return;
|
||||
|
||||
|
||||
if($pingtool)
|
||||
my $temp;
|
||||
if($^O =~ m/Win/)
|
||||
{
|
||||
eval "require Net::Ping;";
|
||||
my $pingtool = Net::Ping->new("syn");
|
||||
|
||||
$retcode = $pingtool->ping($device, 5);
|
||||
$return = "$name|".($retcode ? "present" : "absent");
|
||||
if($pingtool)
|
||||
{
|
||||
$retcode = $pingtool->ping($device, 5);
|
||||
$return = "$name|".($retcode ? "present" : "absent");
|
||||
}
|
||||
else
|
||||
{
|
||||
$return = "$name|error|Could not create a Net::Ping object.";
|
||||
}
|
||||
|
||||
}
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
@ -884,4 +891,4 @@ Options:
|
||||
|
||||
=end html_DE
|
||||
|
||||
=cut
|
||||
=cut
|
||||
|
Loading…
x
Reference in New Issue
Block a user