PDA

View Full Version : Perl Problem


mic2100
12-20-2007, 08:22 PM
Hi,

i have been having a problem for a while now and i can't seem to find a solution to it.

I have a cron job that runs every day and email me the response


page: line 1: my: command not found
page: line 3: use: command not found
page: line 4: my: command not found
page: line 5: die: command not found
page: line 7: print: command not found

Above is the response (and it doesn't do what it is supposed to)

The code is as follows


my $url = 'http://www.somesite.com/somepage.html';

use LWP::Simple;
my $content = get $url;
die "Couldn't get $url" unless defined $content;

print $content;


What i am trying to do is open a webpage that will run all the jobs that i need running each day. I have been trying to find a replacement for this in a CGI script since i know that CGI runs on the server. I also think that the above error are caused by a perl installation with limited functionality since it runs fine on my computer.

Any help would be greatly received.

Thanks

KevinADC
12-20-2007, 09:06 PM
The problem does not appear to be the perl code but the way it is being interpreted. Do you need to include the path to perl in the script on the very first line?

#!/usr/bin/perl

or whatever is appropriate for your computer

mic2100
12-20-2007, 09:26 PM
yeah i was running it on a windows machine, but it as been moved on to a unix webserver. will let you know the results but thanks

KevinADC
12-20-2007, 10:07 PM
windows doesn't normally require/use the shebang line but Unix will so that is most likely the problem.

mic2100
12-21-2007, 11:04 PM
yeah it sorted it thanks