Forum Moderators: coopster & phranque

Message Too Old, No Replies

A newbie needing a little guidance...

         

overthetop

6:44 am on Aug 15, 2003 (gmt 0)

10+ Year Member


I am slowly learning about all these different language (does there have to be soo many? ) but I'm getting stuck on this Perl/CGI thing. GRRR!

Everytime I try to install a script to my site I get the same error. I know it's something that I'm messing up but for the life of me just can't figure out what it is. I am going to put as much of it here as I can without overloading you but I would appreciate as much as and guidance as possible so that I can understand what it is that I'm doing wrong. Thank you in advance for anybody that attempts to help me out in this frustrating time I'm having.

Directions for script:

Installing Hello Baby!
Follow these steps to install and configure the scripts:

copy the "hello_baby" directory (including all subdirectories) in the desired HTML path on your server. Here is a summary of the subdirectories:
(I copied them all into the file "hello_ba"[smilestopper])

babies - This is the subdirectory that will contain the announcements. Permissions on this directory must be set to chmod 777.
(When I FTP'ed them over, I did it in ASCII and changed this subdirectory to 777)

templates - This directory contains the html-based templates for generating individual page designs.

copy the "hello" directory into your cgi directory. Here is a summary of the scripts and what they do:
cgi-lib.pl - A freely-distributed PERL module script.
(I did copy on this directory and pasted it into my cgi-bin directory)

hello_go.pl - the script that actually creates pages.

hello_preview.pl - the script that uploads photos and displays a preview

hello_prefs.pm - shared subroutines

Configuring HTML files
You must specify the web address to hello_preview.pl; You should also look at templates to ensure that any default links to images are accurate for your server.
(I checked out the html files but I didn't see anywhere that I needed to do this to..)

Configuring Scripts
For Hello_Baby to work properly, you must set variables specific to your web site. These include the following:

Variables in hello_prefs.pl:

$mailer - This variable actually determines whether you're using our script on Unix (mail) or NT (Blat/GBMAIL)

$blat/$mail/$gbmail - You only need to define one of these variables based on your mailer selection. It's the location to the mailer. If you select gbmail, you must also define gbmailer-specific variables, as shown in the script.

$home - URL location of the "hello_baby" directory.

$homepath - The file path to "hello_baby" directory.

Other Scripts:
For all other scripts, you only need to ensure that the filepath to PERL in the first line of each script is correct.
(I made sure they were all correct)

Configuring Templates
The templates directory contains templates for all HTML the script generates. They are HTML pages -- do with them what you will.

Now I will include the "edited" parts of the script that I changed...

hello_go.pl:
Unedited:
#!/usr/local/bin/perl
require hello_prefs;
require "cgi-lib.pl";

Edited:
#!/usr/bin/perl
require hello_prefs;
require "cgi-lib.pl";

cgi-lib.pl:
Unedited:
# Parameters affecting cgi-lib behavior
# User-configurable parameters affecting file upload.
$cgi_lib'maxdata = 131072; # maximum bytes to accept via POST - 2^17
$cgi_lib'writefiles = "\\online\\htdocs\\workshop\\hello_baby\\babies"; # directory to which to write files, or
# 0 if files should not be written
#$cgi_lib'filepre = "new"; # Prefix of file names, in directory above

Edited:
# Parameters affecting cgi-lib behavior
# User-configurable parameters affecting file upload.
$cgi_lib'maxdata = 131072; # maximum bytes to accept via POST - 2^17
$cgi_lib'writefiles = "/hsphere/local/home/melodyt/friendsandfamilies.com/hello_ba/hello_ba/babies"; # directory to which to write files, or
# 0 if files should not be written
#$cgi_lib'filepre = "new"; # Prefix of file names, in directory above

hello_preview.pl
Unedited:
#!/usr/bin/perl
use hello_prefs;
require "cgi-lib.pl";

Edited:
#!/usr/bin/perl
use hello_prefs;
require "cgi-lib.pl";

hello_prefs.pm
Unedited:
#!/usr/local/bin/perl

#What's the main URL for your web site?
$home="http://www.onlinearts.net/workshop/hello_baby";

#What's the root file path to your web site?
$homepath="/online/htdocs/workshop/hello_baby";

$pagedir="$homepath/babies";
$counter="$homepath/babies/count.txt";
$weasel="$homepath/babies/weasel.txt";

#which mailer are you using? "Blat/gbmail" (NT) or "mail"?
#$mailer="Blat";# option for NT
#$mailer="gbmail"; # option for NT
#$mailer="mail"; #for unix
$mailer="sendmail"; #for unix

#where is Blat? (For NT if selected)
$blat="/online/cgi-shl/trial/Blat";

#where is gbmail? (ON NT)
$gbmail="/online/cgi-shl/misc/gbmail";
#whats your smtp cost name?
$host="pwc.powerweb.net";
#whats the gbmail return address?
$return="administrator\@onlinearts.net";

#where is mail? (on Unix only)
$mail="/user/bin/mail";


#where is sendmail? (on Unix only)
$sendmail="/usr/lib/sendmail";
#what is the return address?
$from="everybody\@onlinearts.net";

Edited:
#!/usr/bin/perl

#What's the main URL for your web site?
$home="http://www.friendsandfamilies.com/hello_ba/hello_ba";

#What's the root file path to your web site?
$homepath="/hsphere/local/home/melodyt/friendsandfamilies.com/hello_ba/hello_ba";

$pagedir="$homepath/babies";
$counter="$homepath/babies/count.txt";
$weasel="$homepath/babies/weasel.txt";

#which mailer are you using? "sendmail"?
#$mailer="Blat";# option for NT
#$mailer="gbmail"; # option for NT
#$mailer="mail"; #for unix
$mailer="sendmail"; #for unix

#where is Blat? (For NT if selected)
$blat="/online/cgi-shl/trial/Blat";

#where is gbmail? (ON NT)
$gbmail="/online/cgi-shl/misc/gbmail";
#whats your smtp cost name?
$host="pwc.powerweb.net";
#whats the gbmail return address?
$return="administrator\@onlinearts.net";

#where is mail? (on Unix only)
$mail="/user/bin/mail";


#where is sendmail? (on Unix only)
$sendmail="/usr/lib/sendmail";
#what is the return address?
$from="webmaster\@friendsandfamilies.com";

Sorry if I've overloaded it with this but I just want to make sure to give all information so I can figure out what I'm doing wrong. Thank you all so much for helping me out with this.

BlueSky

8:45 am on Aug 15, 2003 (gmt 0)

10+ Year Member



If you are brand new to programming, then IMO you ought to try PHP. It's far easier to learn and the error messages aren't as encryptic. After you get some experience, then delve into Perl if you want.

You didn't post what the error message is that you keep getting. So, I'll take a wild guess that it's a 500 error. If this is the case, it is usually caused by one or more of the following:

-- Some of the files which should have been uploaded as ASCII were actually transferred as binary. Some FTP programs will do this even though they say ASCII. Not sure why it happens. When I play with Perl, I always use SmartFTP because I found it to be fairly consistent in transferring files properly. Whichever client you use make sure it has all the file extensions that must be transferred as ASCII.

-- Permission on the executable files were not changed to 755.

-- If the Perl script is running outside the cgi-bin, the directory does not have an addtype or some panel setting to recognize .cgi and .pl as Perl executables.

-- Paths to Perl or other directories/files are listed incorrectly.

Hopefully, this gives you some idea on where to start looking.

Damian

10:20 am on Aug 15, 2003 (gmt 0)

10+ Year Member



If you indeed get a 500 error (BlueSky's right... try to give as much info on the actual error as possible if you're looking for help) ..

If Bluesky's possible solutions don't solve it for you, try putting the following line just below the shebang line (the path to perl on the first line of every perl script), it will print the error to your browser instead of the logs so you can quickly see what's wrong. Remove the line again when you've got the script working.

If the error message doesn't help you solve the problem it may enable someone here to help you better with the problem.

Add this to your script(s):

use CGI::Carp qw(carpout fatalsToBrowser);

For example:
change

#!/usr/bin/perl

to

#!/usr/bin/perl
use CGI::Carp qw(carpout fatalsToBrowser);

claus

12:43 pm on Aug 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I did spend some time checking your configs posted - none of this seems to be the problem in itself, although it might be anyway if there are typos. If there are, at least they seem consistent - if there are any binary characters, those are always invisible so they're not easy to find.

Lacking the error messages (Damian has a good point in fatals to browser - do try it : ) i can give no extra advice apart from this link to an about.com article on perl script errors, it's three pages and quite understandable even for a complete newbie ;)

[perl.about.com...]

Apart from the obvious (always: ASCII-upload, paths and filenames, and file/directory permissions), the linked page mentions eg. that some servers are not allowed to run cgi's off a subdirectory ("/hello/") of the cgi-bin.

If this is the case you'll have to move your scripts and the "cgi-lib.pl" one directory upstream and perhaps you have to change some references in the scripts if that directory name is required.

/claus

overthetop

2:53 pm on Aug 15, 2003 (gmt 0)

10+ Year Member


I can't believe that I forgot to include the error. Sorry! :[smilestopper]( I was trying to make sure to give you enough information that you would be able to help me that I forgot that part.

This is the error that I get in the browser:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@friendsandfamilies.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

--------------------------------------------------------------------------------

Apache/1.3.27 Server at friendsandfamilies.com Port 80

This is the error in the error log:
[Fri Aug 15 10:44:22 2003] [error] [client 66.229.13.87] Premature end of script headers: /hsphere/local/home/melodyt/friendsandfamilies.com/cgi-bin/hello/hello_preview.pl

I'm so sorry that I forgot to include those.

I did make sure that I FTP'ed in ASCII but I will download the FTP program that was mentioned and try that. I have tried to download about 5 different sripts to my site all Perl/CGI and I have had no luck with any of them. I've tried this particular script about 4 times and each time paid more and more attention to each detail and made sure that I got everything right. I will try a new FTP program and see if that has any difference.

By the way, I did find that PHP was ALOT easier to deal with and add those often to my site. I just have these scripts that I would like to get added as they seem like very good options to have. Thank you all for your replied and again so sorry for forgetting that important part.

overthetop

5:53 pm on Aug 15, 2003 (gmt 0)

10+ Year Member


Well I downloaded SmartFTP and didn't get anywhere. I tried an even easier Perl/CGI script and couldn't get that one to work either. Same error. I just know that it's something so stupid and easy that I'm missing.

All of the files that are FTP'ed need to be chmod 755 then the cgi files need to be 777 or is that wrong?

*pulling out hair*

Damian

6:10 pm on Aug 15, 2003 (gmt 0)

10+ Year Member



>cgi files need to be 777

that's wrong.. cgi files need to be 755

overthetop

6:53 pm on Aug 15, 2003 (gmt 0)

10+ Year Member


Ok then what about the rest of the files? They all need to be 755?

Damian

7:04 pm on Aug 15, 2003 (gmt 0)

10+ Year Member



>They all need to be 755?
No. Just the cgi files.... the .pl files in your example.

I don't know what the permissions should be for the other files. Your templates and data files should probably be 777 but check the manual on that before you change it.. it's likely to be detailed in the install instrcutions which files should have which permissions.

claus

7:14 pm on Aug 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>> Premature end of script

The script "hello_preview.pl" started and then it ended before it should have it seems. If it needs to write to some files that should be 777 but isn't, then that might explain it.

A binary character inside the script is also a possibility. What kind of text editor did you use to make the changes? Did you try "fatals to browser" in "hello_preview.pl" (post #3)?

/claus

overthetop

7:33 pm on Aug 15, 2003 (gmt 0)

10+ Year Member


Ok I've double checked that I had the CHMOD right. I have all the other files set to 755, the "babies" directory set to 777 because that is what the instructions say to do. Then I have the cgi set to 755. (oh this is confusing)

As for the fatals to browser, in what file do I put that in?

The text editor that I use is Arachnophilia. I used to use Dreamweaver then Notepad but keep switching because I have been told the others can cause problems. I just want to get to the bottom of what I'm doing wrong :[smilestopper](

claus

8:19 pm on Aug 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't think it's the arachno thingy... didn't know it, though.

Well i just found and downloaded the hello baby script.. i do understand your frustration, there's absolutely no guidance on permissions.

Try this, i'm just guessing here:

755 cgi-lib.pl
755 hello_go.pl
755 hello_preview.pl
755 hello_prefs.pm

777 /babies/
777 /babies/count.txt
777 /templates/ (or is it "template"?)
777 /templates/all-files-ending-in-htm.htm

I don't know if this directory is supposed to be called templates with or without a "s" in the end, the doc is also unclear here, but in the "hello_prefs" it's hardcoded with an "s" so the s should be there...

Also, in my distribution, the "hello_prefs.pm" is called "hello_pr.pm" so an "efs" must be added.

/claus


added:

Fatals: just like Damian wrote in post #3:

#!/usr/bin/perl
use CGI::Carp qw(carpout fatalsToBrowser);

- in the hello_prefs file (and hello_go)

overthetop

9:48 pm on Aug 15, 2003 (gmt 0)

10+ Year Member


Ok I checked all those CHMOD and added that to the those files. I also added it into the hello_preview because that is the file that the script goes to after completing the fields and pushing enter. This is the error that I get:

Sorry
Some required fields are missing.


I posted all the unedited and edited ones with the instructions. Can anybody see what required information that I could be missing?

Thank you ALL for all the help with this!

claus

12:00 am on Aug 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>> also added to hello_preview

That was the file i was thinking about, i wrote the wrong name

>> Sorry

Well, now it's running it seems... that's the oops routine form "hello_preview.pl" that gets done when these conditions are met:

if ($cgi_data{'babyname'} eq "" ¦¦ $cgi_data{'parent'} eq ""){
&oops;
}

That is: "babyname" or "parent" are missing. You might want to look for "# SORRY" in "hello_preferences.pm" and edit this line to include those two field names:

<TD colspan=\"2\"><P>Some required fields are missing.</p>

- oh, and edit the "index.htm" as well so it does not say "all fields are optional". I really don't think this software is 100% finished and ready for use, i wish i had more time to look at it, as i'm not convinced security is all that good either.

/claus

overthetop

4:30 am on Aug 16, 2003 (gmt 0)

10+ Year Member


Ok with the fatals going to browser that is helping SOO much. Thank you VERY much for that tip. It seems to be working now BUT.. after filling in all the info and what not this is the error I'm getting after saying that I want to publish it:

Not Found
The requested URL /hello_ba/babies/baby_166_makena.html was not found on this server

Obviously it's not creating the pages like it's supposed to. Where would that variable be?

overthetop

4:49 am on Aug 16, 2003 (gmt 0)

10+ Year Member


I've tried messing around with it a little bit and I see where they are going to (the actual pages that the script is making) which is the friendsandfamilies.com/hello_ba/ file with the name of babies/new_baby..... instead of it going into the file hello_ba/babies/

AHHHHHHH It's seems I'm getting closer and have DEFINITELY got some progress but this is a pain...

claus

2:00 pm on Aug 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>> URL /hello_ba/babies/baby_166_makena.html
>> the name of babies/new_baby

There's this code in the hello_go script - numbers are added by me:

-----------------
(1) $babypage=$pagedir."\\baby_".$index."_".$begin.".html";

(2) $babylink="baby_".$index."_".$begin.".html";

(...some lines before email text...)

(3) please visit the following URL:

(4) $home/babies/$babylink
-----------------

and this is what you wrote in the hello_prefs:

-----------------
(5) $home="http://www.your-domain.com/hello_ba/hello_ba";

(6) $homepath="/hsphere/local/home/melodyt/your-domain.com/hello_ba/hello_ba";

(7) $pagedir="$homepath/babies";
-----------------

- indicating that the baby page URL will be:

your-domain.com/hello_ba/hello_ba/babies/baby_xxx_yyy.html (line 1+7+6)

and that the email will print out this url:

http ://www.your-domain.com/hello_ba/hello_ba/babies/baby_xxx_yyy.html (line 4+5+2)

These two addresses are identical, so there should be no problem here... In your cgi-lib however (yes this is complicated) you have written this:

-----------------
(8) $cgi_lib'writefiles = "/.../your-domain.com/hello_ba/hello_ba/babies"; # directory to which to write files, or

(9) #$cgi_lib'filepre = "new"; # Prefix of file names, in directory above
-----------------

- so this is where the "new_" comes from (line 9). The cgi-lib is the thing that is actually writing the files, it just get called from the other scripts. The weird thing is that i do not see the "new" being put to use anywere... The line 9 variable is not referenced in any of the scripts, nor is the word "new".

In the latest released version (source: [cgi-lib.berkeley.edu...] ) , it is being employed in this line:

-----------------
# ($me) = $0 =~ m#([^/]*)$#;
$writefiles .= "/$cgi_lib'filepre";
-----------------

However, in the version you are using these lines are in stead:

-----------------
# ($me) = $0 =~ m#([^/]*)$#;
$writefiles .= "\\$in{$fn}";
-----------------

So basically i think you're using another version than the one you think you are using (a version pre-installed on your server that is.) The one that comes with the script is clearly modified - it is not the official one.

Perhaps i'm not right here, but please try changing the prefix in line 9 (above - in your "cgi-lib.pl") to something else, like "whatever" and see what the filenames of the new baby files are - if they include "whatever" then you should be using the cgi-lib you think.

That's not necessarily good though... there may be a security issue here - there's some parts of the code that are odd, and it's fairly hard to digest with four scripts and html as well, so - it might just be lazy programming or bad finish, but it might as well be a major security hole.

/claus