#!/usr/bin/perl # lists getradio.pl at jobs in a more useful sorted way # Copyright (C) 2005 Karl-Heinz Herrmann # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . use Date::Calc qw(Day_of_Week Day_of_Week_to_Text); open (ATQ,"atq |") or die "Can't get atq output: $!\n"; while ($job=) { $job =~ /(\d+)[\s\t]+([\d-]+)[\s\t]+([\d:]+)\s+([a=]?).*/; $jnr=$1; $date=$2; ($y,$m,$d)=split("-",$date); $wday=Day_of_Week($y,$m,$d); $wday=substr(Day_of_Week_to_Text($wday),0,2); $time=$3; $status=$4; if ($status eq "="){ $status="running"; }else{ $status=""; } open (ATC,"at -c $job |") or die "Can't get at -c output: $!\n"; $command="????"; $dur="??"; $execdir=""; while ($line=){ if ($line =~ /cd (\/.*) \|\| \{/ ){ $execdir=$1; } if ($line =~ /get(dl[rf])-autokill.sh\s+(\d*)/ ){ $command=$1." "; $dur=$2; } if ($line =~ /getWDR([135]).*\.pl\s+(\d*)/ ){ $command="WDR".$1; $dur=$2; } if ($line =~ /getBR([12345]).*\.sh\s+(\d*)/ ){ $command="BR".$1." "; $dur=$2; } if ($line =~ /getradio.pl\s+(.*?)\s+(\d*)/ ){ $command=$1." "; $dur=$2; } } close(ATC); if (defined $atq{$date." ".$time." ".$command}){ print "DOULE ENTRY: ",$date," ",$time," ",$wday." "." "x(4-length($jnr)).$jnr." ".$command." ".$dur." ".$status." ".$execdir."\n"; } $atq{$date." ".$time." ".$command}=$wday." "." "x(4-length($jnr)).$jnr." ".$dur." ".$status." ".$execdir."\n"; } foreach $dt (sort keys %atq){ print $dt," ",$atq{$dt}; }