return to first page linux journal archive
keywordscontents

Listing 2. Copy Program for cron Job

#!/usr/bin/perl -wT
use strict;
use diagnostics;
use vars qw($copyprog $destination
	$now_string @now $day $source);
# Set PATH to avoid security problems
$ENV{PATH} = "/bin/";
# Set this to the copy program
$copyprog = "/bin/cp";
# Set the destination filename
$destination = 
"/usr/local/apache/share/htdocs/today.html";
# Get the current time and date
$now_string = localtime(time);
@now = localtime(time);
# Get the day of the week from @now
$day = $now[6];
# Get the source file
$source = 
"/usr/local/apache/share/htdocs/file-$day.html";
# Copy it to the destination file
`$copyprog $source $destination`;
# Print the result
print "Copy finished on $now_string\n";