/
cron_spec_highlight
executable file
·49 lines (33 loc) · 1.1 KB
/
cron_spec_highlight
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
47
48
49
#!/usr/bin/env perl
use strict;
use warnings;
use English;
use feature qw(say);
# act nice
use POSIX qw(nice);
nice 19;
my $WEB_ROOT='~/public_html';
print <<"INTRO";
Hi my name is $PROGRAM_NAME.
I am usually run as a cron job to generate Perl 6 syntax highlighted htmls.
INTRO
my $status;
say "\n--Running 'git pull' for std";
$status = system('cd ..; git pull');
die "Could not git pull for std\n" if $status != 0;
say "\n--Running 'make clean all' for STD.pm";
$status = system('cd ..; make clean all');
die "Could not make STD.pm\n" if $status != 0;
say "\n-- Running syntax highlighter";
$status = system("cd ..; std_hilite/spec_highlight");
#die "Could not run spec_highlight\n" if $status != 0;
say "\n-- Copying the result to $WEB_ROOT/html";
$status = system("/bin/cp -R ../html $WEB_ROOT/");
die "Could not copy the output\n" if $status != 0;
say "\n-- I am done... Thanks for your valuable time";
=head1 sample usage in cron
PATH=/bin:/usr/bin:/usr/local/bin
LANG=en_US.UTF-8
# m h dom mon dow command
1 */5 * * * (cd ~/std/std_hilite; ./cron_spec_highlight 2>&1 | tee html/log.txt)
=cut