Re: Errors in Perl Function
- From: Andrew DeFaria <Andrew@xxxxxxxxxxx>
- Date: Sun, 26 Nov 2006 23:47:27 -0600
abhi147@xxxxxxxxx wrote:
Hi all ,Lacking any formal shebang line your script is probably being executed by Bourne Shell which lacks function (and and probably isn't that happy about the $(command) syntax either). Try adding #!/bin/bash as the first line.
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
--
Andrew DeFaria <http://defaria.com>
If a mime is arrested do they tell him he has the right to talk?
- References:
- Errors in Perl Function
- From: abhi147
- Errors in Perl Function
- Prev by Date: Re: modPerl, Apache, and REMOTE_USER
- Next by Date: Re: prevent further hash auto-vivification
- Previous by thread: Errors in Perl Function
- Next by thread: Re: Errors in Perl Function
- Index(es):
Relevant Pages
|
|