Forum Moderators: coopster & phranque

Message Too Old, No Replies

Can't get Perl script to run on my server

         

RussellC

9:41 pm on Jul 15, 2002 (gmt 0)

10+ Year Member



I am trying to get this perl script I downloaded to run on my server and I can't seem to get it. I changed the variables that I was supposed to in the script but it still dosnt work. Can anyone help? The form should work correctly because it is just some form that I downloaded. Thanks a bunch.

oilman

9:53 pm on Jul 15, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Russell - can you give us a little more info?

Have you checked the permissions?
Is it using sendmail and is the path right?
Are you sure you have the path to perl correct?
Did you upload it in the correct format? (ie: ascii?)

Those are the little bits that always have always messed me up.

RussellC

10:43 pm on Jul 15, 2002 (gmt 0)

10+ Year Member



>Have you checked the permissions?

yes and they seems to be fine

>Is it using sendmail and is the path right?

yes and the path is correct,
$mail_cmd = '/usr/lib/sendmail';

>Are you sure you have the path to perl correct?

Yes, #!/usr/local/bin/perl

>Did you upload it in the correct format? (ie: ascii?)

Yup, I dunno whats wrong.

These are the init things that I am supposed to change in the instructions.
$content_type = "Content-type: text/html\n\n";
$base_path = '/u/web/myaccount';
$mail_cmd = '/usr/lib/sendmail';
@Referers = ('www.myurl.com','myurl.com');

I think i have them correct but I am not 100% sure about the $base_path var.

Here is what my host says on implementing custom scripts:

Perl Scripts

Upload to your cgi-local directory to ensure proper file permission settings
Upload in ASCII transfer mode (and NOT BINARY mode)
The first line of each script must read: #!/usr/local/bin/perl
Use the Perl script checker in your Control Panel to check syntax.
Always remember to include print "Content-type: text/html\n\n"; or alternatively using the Perl module CGI.pm (If you do not, your scripts will not run and you will get an Internal Server Error message).

They also say:

If a script calls another file within your account, but the script does NOT require a URL, you need to use the system path. Instead of using the absolute path to your home directory ("/www26/web/someid"), you should instead use the DOCUMENT_ROOT environment variable ($ENV{DOCUMENT_ROOT} in Perl) to determine the path of your files or programs within a script.

Change this: /www23/web/yourid/data/fact.html
To this: $ENV{DOCUMENT_ROOT}/data/fact.html

Any ideas?

RussellC

3:13 pm on Jul 16, 2002 (gmt 0)

10+ Year Member



any ideas? thx

Knowles

3:36 pm on Jul 16, 2002 (gmt 0)

10+ Year Member



I would use the absolute path, but that is just my personal preference.

Is it giving you any errors? Does it act like it is sending the email? Does it give you a address not found error in your email box?

RussellC

3:49 pm on Jul 16, 2002 (gmt 0)

10+ Year Member



It gives me a 500 Internal Server Error and thats it. :(

amoore

3:54 pm on Jul 16, 2002 (gmt 0)

10+ Year Member


This is pretty much just a bunch of stuff from about a thousand FAQ's about this topic: I could get more specific, but you haven't even mentioned what you mean by "it's not working". What are the symptons? do you get an "Internal Server Error", or an error page of any kind? do you get a blank page? do you get a page that's just not like it's supposed to be?

Is it actually running and just not behaving correctly, or is it failing to run?

if it's failing to run, run it from the command line, or run it like "perl -c file.cgi" and see what it says. (and then act on that information. The error messages are more important than you think. They're not just there for the programmers' satisfaction.) You can also check the error logs of your server.

There are about a million things that would keep a script from running. One common tricky one is that your file is in wondows format and you have it on a linux machine, so the firs line that looks like "#!/usr/bin/perl" actually has CR/LF line ending problems that keep apache from finding perl correctly. re-type that line. Also, is that the right path to perl? Are all of the necessary modules installed? are the permissions set? is ExecCGI turned on in that directory? for that file extension?

If it is running and just not working right, is it because it's spitting out an error before the headers? what does your error log say?

Knowles

4:12 pm on Jul 16, 2002 (gmt 0)

10+ Year Member



With it being an internal error, I am going to guess its finding perl, so possibly its the sendmail or your base path.

Do you run any other perl scripts?

RussellC

4:17 pm on Jul 16, 2002 (gmt 0)

10+ Year Member



It's got to be my base path...im positive the sendmail is correct. I have tried a million different combos...but i'll keep trying...thanks

RussellC

4:20 pm on Jul 16, 2002 (gmt 0)

10+ Year Member



just ran a test

Output of "perl -c -w cgi-local/af.pl":

/[^\w-\./\\]+/: false [] range "\w-" in regexp at /u/web/mysite/cgi-local/af.pl line 186.
/[^\w-\./\\]+/: false [] range "\w-" in regexp at /u/web/mysite/cgi-local/af.pl line 198.
Name "Mail::Sendmail::error" used only once: possible typo at /u/web/mysite/cgi-local/af.pl line 301.
/u/web/mysite/cgi-local/af.pl syntax OK

Knowles

4:20 pm on Jul 16, 2002 (gmt 0)

10+ Year Member



Does your server support PHP?

If so do this

<?
phpinfo();
?>

Save as something.php then open that in the browser and it should give you the base path in there. If you still cant find it remove the ; from it and it will out put an pharse error in base path/filename.php on line 2.

<added> I dont know perl well enough to make heads or tails of those errors, sorry. Possibly someone more versed in Perl will stick there head in and give you a hand.

[edited by: Knowles at 4:23 pm (utc) on July 16, 2002]

EliteWeb

4:21 pm on Jul 16, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



check to make sure ya didnt upload it in that way that it ends up having little ^M's all over it ;)

RussellC

4:40 pm on Jul 16, 2002 (gmt 0)

10+ Year Member



DOCUMENT_ROOT = /u/web/mysite

Knowles

4:43 pm on Jul 16, 2002 (gmt 0)

10+ Year Member



If thats what you have set as your base path then its correct, and that is not the error. This still leaves us with needing to know what format it is saved in and uploaded. Try deleting the one on the server then reuploading it specifing that it be done in ascii not binary. Your FTP client should give you the option to set it.

amoore

4:58 pm on Jul 16, 2002 (gmt 0)

10+ Year Member



that test you ran with "perl -c -w" is useful. It shows that the syntax is OK (as long as you're not running under 'strict').

Now run it from the command line and see if it dumps out a valid header before anything else. It should start with a few lines like:

Content-type: text/html

and then a blank line.

Also, any reason why you won't look in your webserver error logs? The error logs are everything. The programs will actually tell you what's wrong with themselves.

RussellC

5:04 pm on Jul 16, 2002 (gmt 0)

10+ Year Member



GOT IT. You guys are awesome. I uploaded deleted it and re-uploaded it and it workerd...except for an email problem. But i think I fixed that too. Thanks for all of your help.