| 1 | package Schedule::At; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | require 5.004; | |||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | # Copyright (c) 1997-2012 Jose A. Rodriguez. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use vars qw($VERSION @ISA $TIME_FORMAT $SHELL); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | $VERSION = '1.15'; | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | $SHELL = ''; | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 17 | # Load configuration for this OS | ||||||||||||||||||||||||||||||||||||||||||
| 18 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use Config; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | my @configs = split (/\./, "$Config{'osname'}"); | |||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | ▶ | while (@configs) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | my $subName = 'AtCfg_' . join('_', @configs); | |||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | $subName =~ s/[^\w\d]/_/g; | |||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | eval "&$subName"; # Call configuration subroutine | |||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | ▶ | last if !$@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | pop @configs; | |||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | ▶ | &AtCfg if $@; # Default configuration | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 36 | # Public subroutines | ||||||||||||||||||||||||||||||||||||||||||
| 37 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | $TIME_FORMAT = '%Q%H%M'; # Format for Date::Manip::DateUnix subroutine | |||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | $TAGID = '##### Please, do not remove this Schedule::At TAG: '; | |||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | sub add { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my %params = @_; | |||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | my $command = $AT{($params{FILE} ? 'addFile' : 'add')}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | return &$command($params{JOBID}) if ref($command) eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | my $atTime = _std2atTime($params{TIME}); | |||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | $command =~ s/%TIME%/$atTime/g; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $command =~ s/%FILE%/$params{FILE}/g; | |||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | if ($SHELL) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | $command = "SHELL=$SHELL $command"; | |||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | if ($params{FILE}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | return (system($command) / 256); | |||||||||||||||||||||||||||||||||||||||||
| 60 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 61 | # Ignore signal to die in case at commands fails | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | local $SIG{'PIPE'} = 'IGNORE'; | |||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | open (ATCMD, "| $command"); | |||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | print ATCMD "$TAGID$params{TAG}\n" if $params{TAG}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | print ATCMD ref($params{COMMAND}) eq "ARRAY" ? | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | join("\n", @{$params{COMMAND}}) : $params{COMMAND}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | close (ATCMD); | |||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | return $?; | |||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | 0; | |||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | sub remove { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | my %params = @_; | |||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if ($params{JOBID}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | my $command = $AT{'remove'}; | |||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | return &$command(@_) if ref($command) eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $command =~ s/%JOBID%/$params{JOBID}/g; | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | system($command) >> 8; | |||||||||||||||||||||||||||||||||||||||||
| 87 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | return if !defined $params{TAG}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my %jobs = getJobs(); | |||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | my %return; | |||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | foreach my $job (values %jobs) { | |||||||||||||||||||||||||||||||||||||||||
| 94 | next if !defined($job->{JOBID}) || | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | !defined($job->{TAG}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $job->{"JOBID"} and defined $job->{"TAG"}
MC/DC0%0/2
defined $job->{"JOBID"} and defined $job->{"TAG"}
defined $job->{"JOBID"}
defined $job->{"TAG"}
Truth table0%0/3
A and B
A= defined $job->{"JOBID"}B= defined $job->{"TAG"}
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | if ($job->{JOBID} && $params{TAG} eq $job->{TAG}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$job->{"JOBID"} and $params{"TAG"} eq $job->{"TAG"}
MC/DC0%0/2
$job->{"JOBID"} and $params{"TAG"} eq $job->{"TAG"}
$job->{"JOBID"}
$params{"TAG"} eq $job->{"TAG"}
Truth table0%0/3
A and B
A= $job->{"JOBID"}B= $params{"TAG"} eq $job->{"TAG"}
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | $return{$job->{JOBID}} = | ||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | remove(JOBID => "$job->{JOBID}") | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | return \%return | |||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | sub getJobs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getJobs: not called CC=13 SCAR=52.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | my %param = @_; | |||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | my %jobs; | |||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | my $command = $AT{'getJobs'}; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | return &$command(@_) if ref($command) eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | open (ATCMD, "$command |") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | or die "Schedule::At: Can't exec getJobs command: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | line: while (defined (my $atLine = <ATCMD>)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | if (defined $AT{'headings'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | foreach my $head (@{$AT{'headings'}}) { | |||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | next line if $atLine =~ /$head/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | chomp $atLine; | |||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my %atJob; | |||||||||||||||||||||||||||||||||||||||||
| 127 | ($atJob{JOBID}, $atJob{TIME}) | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | = &{$AT{'parseJobList'}}($atLine); | |||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $atJob{TAG} = _getTag(JOBID => $atJob{JOBID}); | |||||||||||||||||||||||||||||||||||||||||
| 130 | next if $param{TAG} && | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | (!$atJob{TAG} || $atJob{TAG} ne $param{TAG}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$param{"TAG"} and !$atJob{"TAG"} || $atJob{"TAG"} ne $param{"TAG"}
not $atJob{"TAG"} or $atJob{"TAG"} ne $param{"TAG"}
MC/DC0%0/3
$param{"TAG"} and !$atJob{"TAG"} || $atJob{"TAG"} ne $param{"TAG"}
$param{"TAG"}
not $atJob{"TAG"}
$atJob{"TAG"} ne $param{"TAG"}
Truth table0%0/4
A and not(B) or C
A= $param{"TAG"}B= not $atJob{"TAG"}C= $atJob{"TAG"} ne $param{"TAG"}
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | next if $param{JOBID} && | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | (!$atJob{JOBID} || $atJob{JOBID} ne $param{JOBID}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$param{"JOBID"} and !$atJob{"JOBID"} || $atJob{"JOBID"} ne $param{"JOBID"}
not $atJob{"JOBID"} or $atJob{"JOBID"} ne $param{"JOBID"}
MC/DC0%0/3
$param{"JOBID"} and !$atJob{"JOBID"} || $atJob{"JOBID"} ne $param{"JOBID"}
$param{"JOBID"}
not $atJob{"JOBID"}
$atJob{"JOBID"} ne $param{"JOBID"}
Truth table0%0/4
A and not(B) or C
A= $param{"JOBID"}B= not $atJob{"JOBID"}C= $atJob{"JOBID"} ne $param{"JOBID"}
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | $jobs{$atJob{JOBID}} = \%atJob; | |||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | close (ATCMD); | |||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | %jobs; | |||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | sub readJobs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readJobs: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | my %jobs = getJobs(@_); | |||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my @job_ids = map { $_->{JOBID} } values %jobs; | |||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | my %content; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | foreach my $jobid (@job_ids) { | |||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $content{$jobid} = _readJob(JOBID => $jobid); | |||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | %content | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 155 | # Private subroutines | ||||||||||||||||||||||||||||||||||||||||||
| 156 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | sub _readJob { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_readJob: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | my %params = @_; | |||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | my $command = $AT{'getCommand'}; | |||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | $command = &$command($params{JOBID}) if ref($command) eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | $command =~ s/%JOBID%/$params{JOBID}/g; | |||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | local $/ = undef; # slurp mode | |||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | open (JOB, "$command") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | or die "Can't open $command: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my $job = <JOB>; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | close (JOB); | |||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | $job | |||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | sub _getTag { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_getTag: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my %params = @_; | |||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | my $job = _readJob(@_); | |||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $job =~ /$TAGID(.*)$/m; | |||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | return $1; | |||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | my @job = split("\n", _readJob(@_)); | |||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | foreach my $commandLine (@job) { | |||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | return $1 if $commandLine =~ /$TAGID(.*)$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | undef; | |||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | sub _std2atTime { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_std2atTime: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | my ($stdTime) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | # StdTime: YYYYMMDDHHMM | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | my ($year, $month, $day, $hour, $mins) = | |||||||||||||||||||||||||||||||||||||||||
| 195 | $stdTime =~ /(....)(..)(..)(..)(..)/; | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my $timeFormat = $AT{'timeFormat'}; | |||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | return &$timeFormat($year, $month, $day, $hour, $mins) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | if ref($timeFormat) eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | $timeFormat =~ s/%YEAR%/$year/g; | |||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | $timeFormat =~ s/%MONTH%/$month/g; | |||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | $timeFormat =~ s/%DAY%/$day/g; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | $timeFormat =~ s/%HOUR%/$hour/g; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | $timeFormat =~ s/%MINS%/$mins/g; | |||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $timeFormat; | |||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | Schedule::At - OS independent interface to the Unix 'at' command | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | require Schedule::At; | ||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | Schedule::At::add(TIME => $string, COMMAND => $string [, TAG =>$string]); | ||||||||||||||||||||||||||||||||||||||||||
| 219 | Schedule::At::add(TIME => $string, COMMAND => \@array [, TAG =>$string]); | ||||||||||||||||||||||||||||||||||||||||||
| 220 | Schedule::At::add(TIME => $string, FILE => $string) | ||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | %jobs = Schedule::At::getJobs(); | ||||||||||||||||||||||||||||||||||||||||||
| 223 | %jobs = Schedule::At::getJobs(JOBID => $string); | ||||||||||||||||||||||||||||||||||||||||||
| 224 | %jobs = Schedule::At::getJobs(TAG => $string); | ||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | Schedule::At::readJobs(JOBID => $string); | ||||||||||||||||||||||||||||||||||||||||||
| 227 | Schedule::At::readJobs(TAG => $string); | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | Schedule::At::remove(JOBID => $string); | ||||||||||||||||||||||||||||||||||||||||||
| 230 | Schedule::At::remove(TAG => $string); | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | This modules provides an OS independent interface to 'at', the Unix | ||||||||||||||||||||||||||||||||||||||||||
| 235 | command that allows you to execute commands at a specified time. | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | =item Schedule::At::add | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | Adds a new job to the at queue. | ||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | You have to specify a B<TIME> and a command to execute. The B<TIME> has | ||||||||||||||||||||||||||||||||||||||||||
| 244 | a common format: YYYYMMDDHHmm where B<YYYY> is the year (4 digits), B<MM> | ||||||||||||||||||||||||||||||||||||||||||
| 245 | the month (01-12), B<DD> is the day (01-31), B<HH> the hour (00-23) and | ||||||||||||||||||||||||||||||||||||||||||
| 246 | B<mm> the minutes. | ||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | The command is passed with the B<COMMAND> or the B<FILE> parameter. | ||||||||||||||||||||||||||||||||||||||||||
| 249 | B<COMMAND> can be used to pass the command as an string, or an array of | ||||||||||||||||||||||||||||||||||||||||||
| 250 | commands, and B<FILE> to read the commands from a file. | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | The optional parameter B<TAG> serves as an application specific way to | ||||||||||||||||||||||||||||||||||||||||||
| 253 | identify a job or a set of jobs. | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | Returns 0 on success or a value != 0 if an error occurred. | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | =item Schedule::At::readJobs | ||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | Read the job content identified by the B<JOBID> or B<TAG> parameters. | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | Returns a hash of JOBID => $string where $string is the the job | ||||||||||||||||||||||||||||||||||||||||||
| 262 | content. As the operating systems usually add a few environment settings, | ||||||||||||||||||||||||||||||||||||||||||
| 263 | the content is longer than the command provided when adding the job. | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | =item Schedule::At::remove | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | Remove an at job. | ||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | You identify the job to be deleted using the B<JOBID> parameter (an | ||||||||||||||||||||||||||||||||||||||||||
| 270 | opaque string returned by the getJobs subroutine). You can also specify | ||||||||||||||||||||||||||||||||||||||||||
| 271 | a job or a set of jobs to delete with the B<TAG> parameter, removing | ||||||||||||||||||||||||||||||||||||||||||
| 272 | all the jobs that have the same tag (as specified with the add subroutine). | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | Used with JOBID, returns 0 on success or a value != 0 if an error occurred. | ||||||||||||||||||||||||||||||||||||||||||
| 275 | Used with TAG, returns a hash reference where the keys are the JOBID of | ||||||||||||||||||||||||||||||||||||||||||
| 276 | the jobs found and the values indicate the success of the remove operation. | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | =item Schedule::At::getJobs | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | Called with no params returns a hash with all the current jobs or | ||||||||||||||||||||||||||||||||||||||||||
| 281 | dies if an error has occurred. | ||||||||||||||||||||||||||||||||||||||||||
| 282 | It's possible to specify the B<TAG> or B<JOBID> parameters so only matching | ||||||||||||||||||||||||||||||||||||||||||
| 283 | jobs are returned. | ||||||||||||||||||||||||||||||||||||||||||
| 284 | For each job the key is a JOBID (an OS dependent string that shouldn't be | ||||||||||||||||||||||||||||||||||||||||||
| 285 | interpreted), and the value is a hash reference. | ||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | This hash reference points to a hash with the keys: | ||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||
| 291 | =item TIME | ||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | An OS dependent string specifying the time to execute the command | ||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | =item TAG | ||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | The tag specified in the Schedule::At::add subroutine | ||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | =head1 Configuration Variables | ||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | $Schedule::At::SHELL | ||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | This variable can be used to specify shell for execution of the scheduled command. | ||||||||||||||||||||||||||||||||||||||||||
| 312 | Can be useful for example when scheduling from CGI script and the account of the user under which httpd runs | ||||||||||||||||||||||||||||||||||||||||||
| 313 | is locked by using '/bin/false' or similar as a shell. | ||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||
| 315 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | =head1 EXAMPLES | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | use Schedule::At; | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | # 1 | ||||||||||||||||||||||||||||||||||||||||||
| 323 | Schedule::At::add (TIME => '199801181530', COMMAND => 'ls', | ||||||||||||||||||||||||||||||||||||||||||
| 324 | TAG => 'ScheduleAt'); | ||||||||||||||||||||||||||||||||||||||||||
| 325 | # 2 | ||||||||||||||||||||||||||||||||||||||||||
| 326 | @cmdlist = ("ls", "echo hello world"); | ||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | Schedule::At::add (TIME => '199801181630', COMMAND => \@cmdlist, | ||||||||||||||||||||||||||||||||||||||||||
| 329 | TAG => 'ScheduleAt'); | ||||||||||||||||||||||||||||||||||||||||||
| 330 | # 3 | ||||||||||||||||||||||||||||||||||||||||||
| 331 | Schedule::At::add (TIME => '199801181730', COMMAND => 'df'); | ||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | # This will remove #1 and #2 but no #3 | ||||||||||||||||||||||||||||||||||||||||||
| 334 | Schedule::At::remove (TAG => 'ScheduleAt'); | ||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | my %atJobs = Schedule::At::getJobs(); | ||||||||||||||||||||||||||||||||||||||||||
| 337 | foreach my $job (values %atJobs) { | ||||||||||||||||||||||||||||||||||||||||||
| 338 | print "\t", $job->{JOBID}, "\t", $job->{TIME}, ' ', | ||||||||||||||||||||||||||||||||||||||||||
| 339 | ($job->{TAG} || ''), "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | Jose A. Rodriguez (jose AT rodriguez.jp) | ||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 349 | # OS dependent code | ||||||||||||||||||||||||||||||||||||||||||
| 350 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | sub AtCfg { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AtCfg: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | # Currently the default configuration just aborts | ||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | die "SORRY! There is no config for this OS.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | sub AtCfg_solaris { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AtCfg_solaris: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | $AT{'add'} = 'at %TIME% 2> /dev/null'; | |||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | $AT{'addFile'} = 'at -f %FILE% %TIME% 2> /dev/null'; | |||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | $AT{'timeFormat'} = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | my ($year, $month, $day, $hour, $mins) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | my @months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', | |||||||||||||||||||||||||||||||||||||||||
| 364 | 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); | ||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | "$hour:$mins " . $months[$month-1] . " $day, $year"; | |||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | $AT{'remove'} = 'at -r %JOBID%'; | |||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | $AT{'getJobs'} = 'at -l'; | |||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | $AT{'headings'} = []; | |||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | $AT{'getCommand'} = '/usr/spool/cron/atjobs/%JOBID%'; | |||||||||||||||||||||||||||||||||||||||||
| 372 | # Ignore "user = xxx" when executed by root | ||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | $AT{'parseJobList'} = sub { $_[0] =~ /^.*(\d{10}.a)\s+(.*)$/ }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | ▶ | sub AtCfg_sunos { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AtCfg_sunos: not called CC=1 SCAR=3.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | &AtCfg_solaris; | |||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | $AT{'getCommand'} = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=17.3
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | my ($jobid) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | for my $filename (glob('/usr/spool/cron/atjobs/*')) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | return $filename if (stat($filename))[1] == $jobid; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | undef; | |||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | sub AtCfg_dec_osf { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AtCfg_dec_osf: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | &AtCfg_solaris; | |||||||||||||||||||||||||||||||||||||||||
| 391 | # josear.1137594600.a Wed Jan 18 15:30:00 2006 | ||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | $AT{'parseJobList'} = sub { $_[0] =~ /^(\S+)\s+(.*)$/ }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | sub AtCfg_hpux { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AtCfg_hpux: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | $AT{'add'} = 'at %TIME% 2> /dev/null'; | |||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | $AT{'addFile'} = 'at -f %FILE% %TIME% 2> /dev/null'; | |||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | $AT{'timeFormat'} = '%HOUR%:%MINS% %MONTH%/%DAY%/%YEAR%'; | |||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | $AT{'remove'} = 'at -r %JOBID%'; | |||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | $AT{'getJobs'} = 'at -l'; | |||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | $AT{'headings'} = []; | |||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | $AT{'getCommand'} = '/usr/spool/cron/atjobs/%JOBID%'; | |||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | $AT{'parseJobList'} = sub { $_[0] =~ /^(\S+)\s+(.*)$/ }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||
| 406 | 1 | ▶ | sub AtCfg_linux { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AtCfg_linux: called CC=1 SCAR=0.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 407 | 1 | $AT{'add'} = 'at %TIME% 2> /dev/null'; | |||||||||||||||||||||||||||||||||||||||||
| 408 | 1 | $AT{'addFile'} = 'at -f %FILE% %TIME% 2> /dev/null'; | |||||||||||||||||||||||||||||||||||||||||
| 409 | 1 | $AT{'timeFormat'} = '%HOUR%:%MINS% %MONTH%/%DAY%/%YEAR%'; | |||||||||||||||||||||||||||||||||||||||||
| 410 | 1 | $AT{'remove'} = 'atrm %JOBID%'; | |||||||||||||||||||||||||||||||||||||||||
| 411 | 1 | $AT{'getJobs'} = 'atq'; | |||||||||||||||||||||||||||||||||||||||||
| 412 | 1 | $AT{'headings'} = ['Date']; | |||||||||||||||||||||||||||||||||||||||||
| 413 | 1 | $AT{'getCommand'} = 'at -c %JOBID% |'; | |||||||||||||||||||||||||||||||||||||||||
| 414 | # 1 2003-01-18 15:30 a josear | ||||||||||||||||||||||||||||||||||||||||||
| 415 | # 10 Tue Jan 31 10:00:00 2012 a josear (debian) | ||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | $AT{'parseJobList'} = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | my @fields = split("\t", $_[0]); | |||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | my $date = substr($fields[1], 0, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 419 | ($fields[1] =~ /^d/) ? 16 : 24); | ||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ($fields[0], $date) | |||||||||||||||||||||||||||||||||||||||||
| 421 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | sub AtCfg_aix { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AtCfg_aix: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | $AT{'add'} = 'at -t %TIME% 2> /dev/null'; | |||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | $AT{'addFile'} = 'at -f %FILE% %TIME% 2> /dev/null'; | |||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | $AT{'timeFormat'} = '%YEAR%%MONTH%%DAY%%HOUR%%MINS%'; | |||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | $AT{'remove'} = 'at -r %JOBID%'; | |||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | $AT{'getJobs'} = 'at -l'; | |||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | $AT{'headings'} = []; | |||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||
| 432 | # Only for privileged users (group system), so use alternate command | ||||||||||||||||||||||||||||||||||||||||||
| 433 | #$AT{'getCommand'} = '/usr/spool/cron/atjobs/%JOBID%'; | ||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | $AT{'getCommand'} = 'at -lv %JOBID% |tail +4 |'; | |||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | $AT{'parseJobList'} = sub { $_[0] =~ /^(\S+)\s+(.*)$/ }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | ▶ | sub AtCfg_dynixptx { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AtCfg_dynixptx: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | $AT{'add'} = 'at %TIME% 2> /dev/null'; | |||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | $AT{'addFile'} = 'at -f %FILE% %TIME% 2> /dev/null'; | |||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | $AT{'timeFormat'} = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | my ($year, $month, $day, $hour, $mins) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | my @months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', | |||||||||||||||||||||||||||||||||||||||||
| 446 | 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); | ||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | "$hour:$mins " . $months[$month-1] . " $day, $year"; | |||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | $AT{'remove'} = 'at -r %JOBID%'; | |||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | $AT{'getJobs'} = 'at -l'; | |||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | $AT{'headings'} = []; | |||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | $AT{'getCommand'} = '/usr/spool/cron/atjobs/%JOBID%'; | |||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | $AT{'parseJobList'} = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | my $user = scalar getpwuid $<; | |||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | if ($user eq 'root') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | $_[0] =~ /^\s*\S+\s*\S+\s*\S+\s*(\S+)\s+(.*)$/ | |||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||
| 459 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | $_[0] =~ /(\S+)\s+(.*)$/ | |||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | sub AtCfg_freebsd { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AtCfg_freebsd: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | $AT{'add'} = 'at %TIME% 2> /dev/null'; | |||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | $AT{'addFile'} = 'at -f %FILE% %TIME% 2> /dev/null'; | |||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | ▶ | $AT{'timeFormat'} = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | my ($year, $month, $day, $hour, $mins) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | my @months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', | |||||||||||||||||||||||||||||||||||||||||
| 472 | 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); | ||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | "$hour:$mins " . $months[$month-1] . " $day $year"; | |||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | $AT{'remove'} = 'atrm %JOBID%'; | |||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | $AT{'getJobs'} = 'at -l'; | |||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | $AT{'headings'} = ['Date', 'Owner', 'Queue', 'Job']; | |||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | $AT{'getCommand'} = 'at -c %JOBID% | '; | |||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | ▶ | $AT{'parseJobList'} = sub { $_[0] =~ s/^\s*(.+)\s+\S+\s+\S+\s+(\d+)$/$2_$1/; $_[0] =~ /^(.+)_(.+)$/ }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | sub AtCfg_netbsd { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AtCfg_netbsd: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | &AtCfg_freebsd; | |||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | ▶ | sub AtCfg_dragonfly { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AtCfg_dragonfly: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | &AtCfg_freebsd; | |||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | sub AtCfg_openbsd { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AtCfg_openbsd: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | &AtCfg_freebsd; | |||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | $AT{'headings'} = []; | |||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | ▶ | $AT{'parseJobList'} = sub { $_[0] =~ /^.*(\d{10}.c)\s+(.*)$/ }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||
| 497 | # Mac OS X (darwin, tiger) | ||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | ▶ | sub AtCfg_darwin { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AtCfg_darwin: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | $AT{'add'} = 'at %TIME% 2> /dev/null'; | |||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | $AT{'addFile'} = 'at -f %FILE% %TIME% 2> /dev/null'; | |||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | $AT{'timeFormat'} = '%HOUR%:%MINS% %MONTH%/%DAY%/%YEAR%'; | |||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | $AT{'remove'} = 'atrm %JOBID%'; | |||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | $AT{'getJobs'} = 'atq'; | |||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | $AT{'headings'} = ['Job','Date']; | |||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | $AT{'getCommand'} = 'at -c %JOBID% | '; | |||||||||||||||||||||||||||||||||||||||||
| 506 | # 74 Wed Jan 18 15:32:00 2006 | ||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | $AT{'parseJobList'} = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | my @fields = split("\t", $_[0]); | |||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | ($fields[0], substr($fields[1], 0, 16)) | |||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||