A
abhi147
Hi all ,
I have a shell script which has a small function to find previous
day's date , which is a perl function.
When I run this script on the command line , the script runs
successfully . Whereas when I run it as a cron job , it gives errors .
The perl function in the shell script is :
### To get yesterday's date ###
function get_yesterday {
perl << "EOF"
my ($mday, $mon, $year) = (localtime(time()-86400))[3,4,5];
$mon++;
$year += 1900;
printf("%04d-%02d-%02d\n", $year, $mon, $mday);
EOF
}
yesterday=$(get_yesterday)
The errors encountered were :
$ ./test.sh
../test.sh: function: not found
2006-11-23
../test.sh: syntax error at line 15: `}' unexpected
Can anyone please tell me .. that do I need to do something extra to
run this script through crontab ?
Thanks
I have a shell script which has a small function to find previous
day's date , which is a perl function.
When I run this script on the command line , the script runs
successfully . Whereas when I run it as a cron job , it gives errors .
The perl function in the shell script is :
### To get yesterday's date ###
function get_yesterday {
perl << "EOF"
my ($mday, $mon, $year) = (localtime(time()-86400))[3,4,5];
$mon++;
$year += 1900;
printf("%04d-%02d-%02d\n", $year, $mon, $mday);
EOF
}
yesterday=$(get_yesterday)
The errors encountered were :
$ ./test.sh
../test.sh: function: not found
2006-11-23
../test.sh: syntax error at line 15: `}' unexpected
Can anyone please tell me .. that do I need to do something extra to
run this script through crontab ?
Thanks