print $cmdfh $cmdstr;
my $res = <$outfh>;
- chop($res);
+ if (defined $res) {
+ chop($res);
+ }
+
print $cmdfh "exit\n";
close $outfh;
print $cmdfh $cmdstr;
my $res = <$outfh>;
- chop($res);
+ if (defined $res) {
+ chop($res);
+ } else {
+ print_and_exit($cmdfh, $outfh, 1, "ERROR! Cmd $cmdstr returned null value!\n");
+ }
+
if ($res ne "0000 ") {
print_and_exit($cmdfh, $outfh, 1, "ERROR! Command $cmd failed with code $res\n");
}
send_cmd($cmdfh, $outfh, "PRINT", $cmdstr);
my $res = <$outfh>;
- chop($res);
+ if (defined $res) {
+ chop($res);
+ } else {
+ print_and_exit($cmdfh, $outfh, 1, "ERROR! Cmd $cmdstr returned null value!\n");
+ }
if ($res eq "0xffffffff") {
send_cmd($cmdfh, $outfh, "PRINT", $cmdstr);
my $err = <$outfh>;
- chop($err);
+ if (defined $err) {
+ chop($err);
+ } else {
+ print_and_exit($cmdfh, $outfh, 1, "ERROR! Cmd $cmdstr returned null value!\n");
+ }
+
print_and_exit($cmdfh, $outfh, 1, "ERROR! $cmd returned $err\n");
}
return $res;