-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathonewire-depend
46 lines (40 loc) · 1019 Bytes
/
onewire-depend
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/perl -w
use strict;
use Getopt::Long;
my ($device1, $device2, $test1, $test2, $verbose, $help);
my $status;
Getopt::Long::Configure('bundling');
GetOptions(
"device1=s" => \$device1,
"device2=s" => \$device2,
"test1=s" => \$test1,
"test2=s" => \$test2,
"v" => \$verbose, "verbose" => \$verbose,
"h" => \$help, "help" => \$help,
);
$help = 1 unless ($device1);
$help = 1 unless ($device2);
$help = 1 unless ($test1);
$help = 1 unless ($test2);
if ($help) {
print "Valid options:
--device1=<DeviceName> # REQUIRED
--device2=<DeviceName> # REQUIRED
--test1=<TestName> # REQUIRED
--test2<TestName> # REQUIRED
-v|--verbose
-h|--help
";
exit 3;
}
my $ReturnedData;
$ReturnedData=`/usr/local/bin/onewire-query --device="$device1" --test="$test1" --state || /usr/local/bin/onewire-query --device="$device2" --test="$test2" --state`;
chomp($ReturnedData);
if ($? == -1) {
print "ERROR: check failed to run: $!\n";
exit 3;
} else {
$? = ($? >> 8);
print "$ReturnedData\n";
exit $?;
}