Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use Device::SerialPort;
- use Sys::Syslog;
- $interval = 180;
- if (lc(@ARGV[0]) eq "test")
- {
- $test = true;
- if ($#ARGV == 1) {$interval = @ARGV[1];}
- }
- $output = `/usr/bin/perl /usr/local/bin/svdrpsend NEXT rel`;
- if ($output =~ m/250\s(\d+)\s(-*\d+)/g)
- {
- $wakeuptime = $2;
- }
- if ($test && defined $wakeuptime && $wakeuptime <= $interval)
- {
- $output = `/usr/bin/perl /usr/local/bin/svdrpsend LSTT $1`;
- if ($output =~ m/250\s\d+\s\d:\d+:[^:]+:(\d+):(\d+)/g)
- {
- $rec = ($2-$1)*60+$wakeuptime;
- print "recording:$rec\n";
- exit 1;
- }
- exit -1;
- }
- elsif ($test)
- {
- exit 0;
- }
- if (defined $wakeuptime && $wakeuptime > 180)
- {
- $secs = $wakeuptime - 180;
- syslog('notice', "HTPC-Timer: $secs");
- $out = pack("WL", ord('t'), $secs);
- my $port = Device::SerialPort->new("/dev/ttyHTPC");
- $port->write($out);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement