2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 09:16:53 +00:00

PRESENCE: fix "Use of uninitialized value" log entries when qx() returns undef (Forum: #55290)

git-svn-id: https://svn.fhem.de/fhem/trunk@11745 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
markusbloch 2016-07-05 16:49:41 +00:00
parent 74d0cc83d2
commit ab66fa8de0

View File

@ -634,9 +634,9 @@ PRESENCE_DoLocalPingScan($)
{
$temp = qx(ping -n $count -4 $device);
chomp $temp;
if($temp ne "")
if(defined($temp) and $temp ne "")
{
chomp $temp;
Log3 $name, 5, "PRESENCE ($name) - ping command returned with output:\n$temp";
$return = "$name|$local|".($temp =~ /TTL=\d+/ ? "present" : "absent");
}
@ -649,9 +649,9 @@ PRESENCE_DoLocalPingScan($)
{
$temp = qx(ping $device 4);
chomp $temp;
if($temp ne "")
if(defined($temp) and $temp ne "")
{
chomp $temp;
Log3 $name, 5, "PRESENCE ($name) - ping command returned with output:\n$temp";
$return = "$name|$local|".($temp =~ /is alive/ ? "present" : "absent");
}
@ -659,14 +659,15 @@ PRESENCE_DoLocalPingScan($)
{
$return = "$name|$local|error|Could not execute ping command: \"ping -n $count -4 $device\"";
}
}
else
{
$temp = qx(ping -c $count $device 2>&1);
chomp $temp;
if($temp ne "")
if(defined($temp) and $temp ne "")
{
chomp $temp;
Log3 $name, 5, "PRESENCE ($name) - ping command returned with output:\n$temp";
$return = "$name|$local|".(($temp =~ /\d+ [Bb]ytes (from|von)/ and not $temp =~ /[Uu]nreachable/) ? "present" : "absent");
}
@ -848,7 +849,6 @@ PRESENCE_DoLocalBluetoothScan($)
if(-x $hcitool)
{
my $options = ($btdevice ? "-i $btdevice" : "");
while($wait)
@ -904,11 +904,13 @@ PRESENCE_DoLocalShellScriptScan($)
$SIG{CHLD} = 'IGNORE';
$ret = qx($call);
chomp $ret;
Log3 $name, 5, "PRESENCE ($name) - script output: $ret";
if(defined($ret))
{
chomp $ret;
Log3 $name, 5, "PRESENCE ($name) - script output: $ret";
}
if(not defined($ret))
{
$return = "$name|$local|error|scriptcall doesn't return any output";
@ -979,7 +981,6 @@ PRESENCE_ProcessLocalScan($)
{
my ($string) = @_;
return unless(defined($string));
my @a = split("\\|",$string);