anmaco has asked for the wisdom of the Perl Monks concerning the following question:

Hi all Real beginners questions these ! I just put my first site online yesterday http://www.anmaco.f2s.com and the visitors book doesn't work. I can't read to or write without a server error message. The support from the site managers have given me a check list but I don't know how to do some of the things on it - can you help? I designed the site on a Windows system with Dreamweaver (is this relevant)? Here are the appropriate bits from the checklist : Has the execute bit been set on the Perl file? HOW? Ensure the script and the directory the script is in are not writable by others - AGAIN - HOW? Has your base path been set correctly? The base path given is /web/sites/162/anmaco/www.anmaco.f2s.com but I don't know where to use it? My scripts are in my cgi-bin right inside my site directory. I feel I am missing some vital point here. It also suggests I might try to chmod 755, but again I don't know how. What a dunce! Thanks for any help you can give me! Just in case it helps here is my coding, which works just fine on my XITAMI server on my local disk! Sorry about the French/English mix.
#!/usr/bin/perl # Ouvrir le fichier $i=0; if (open (FICHIER, "<gbook.txt") != false) { # flock (FICHIER, 1); # verrouille en lecture $max=0; while (<FICHIER>) { push(@Lignes,$_); $max++; } # flock (FICHIER, 8); # déverrouille close (FICHIER); # Sortie vers le navigateur : print "Content-type: text/html\n\n"; print <<html_fin; <HTML> <HEAD> <TITLE>Visitor's Book</TITLE> </HEAD> <body bgcolor="#FFFFFF" background="../Backgrounds/parch2.jpg"> <img src="../Pictures/ourvisitorsbook2.jpg" width="758" height="231"> <p align="center"> </p> <p align="center"><font face="Comic Sans MS, Arial" size="+2" color="# +652C16">Here are the messages we have received</font></p> <p> </p> html_fin for ($i=0; $i<$max; $i+=6) { $time = @Lignes[$i+0]; $PNom = @Lignes[$i+1]; $NomFam = @Lignes[$i+2]; $email = @Lignes[$i+3]; $subject = @Lignes[$i+4]; $body = @Lignes[$i+5]; print "<B>", $PNom, " ", $NomFam, "</B> (<B><A HREF=\"mailto:", $email, "\">", $email, "</A></B>)<BR><BR>\n"; print "wrote on <B>", $time, "</B> on the subject <B>", $subject, "</B>:<BR><BR>\n"; print "<I>", $body, "</I><HR>\n"; } print <<html_fin; <p align="center"><font face="Comic Sans MS, Arial" color="#652C16">"I +f you would like, you can also <a href="../Drop_us_a_line.htm">write +a message</a> in our Visitor's Book, or <a href="../Index.htm">go bac +k</a> to the Homepage.</font> </p> <p> </p> <p align="center"><font face="Comic Sans MS, Arial" color="#652C16"><i +><font size="+1"><b><u>Have fun!</u></b<</font></i></font></p> <p>  </p> </BODY> </HTML> html_fin } else # erreur fichier { print <<html_fin; <HTML> <HEAD> <TITLE>Erreur</TITLE> </HEAD> <BODY> <B>Impossible to read the Visitor's Book</B> <P> Please <A HREF="../index.html">go back</A> to the Homepage. <P> <I><B>Have fun!</B></I> </BODY> </HTML> html_fin } exit;
AND
#!/usr/bin/perl # Exploiter les variables d'environnement : if($ENV{'REQUEST_METHOD'} eq 'GET') { $Data = $ENV{'QUERY_STRING'} } else { read(STDIN, $Data, $ENV{'CONTENT_LENGTH'}) } $i=0; @ChampsFormulaire = split(/&/, $Data); foreach $Champ (@ChampsFormulaire) { ($name, $value) = split(/=/, $Champ); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/<!--(.|\n)*-->//g; $value =~ s/\n/<BR>/g; # transformer Newline en <BR> $Formulaire[$i] = $name; $i = $i + 1; $Formulaire[$i] = $value; $i = $i + 1; } # Extraire date et heure $ValActu = time(); $HeureActu = localtime($ValActu); # ouvre le fichier pour l'adjonction if (open (FICHIER, ">>gbook.txt") != false) { # flock (FICHIER, 2); # verouille en écriture print FICHIER "$HeureActu\n"; for ($i=0; $i<=$#Formulaire; $i=$i+2) { print FICHIER $Formulaire[$i+1], "\n"; } # flock (FICHIER, 8); # déverrouille close (FICHIER); # Sortie vers le navigateur : print "Content-type: text/html\n\n"; print <<html_fin; <HTML> <HEAD> <TITLE>Merci</TITLE> </HEAD> <BODY> <B>Thank you for adding to my Visitor's Book.</B> <P> You can now ' <A HREF="read_lo.pl">read</A> your message, and all the others... or <A HREF="../index.html">return</A> to my Homepage. <P> <I><B>Have fun !</B></I> </BODY> </HTML> html_fin } else # erreur fichier { # Sortie vers le navigateur : print "Content-type: text/html\n\n"; print <<html_fin; <HTML> <HEAD> <TITLE>Erreur</TITLE> </HEAD> <BODY> <B>Impossible to write in the Visitor's Book</B> <P> You can <A HREF="../index.html">return</A> to my Homepage. <P> <I><B>Have fun !</B></I> </BODY> </HTML> html_fin } exit;

Replies are listed 'Best First'.
Re: Server Error Messages
by BigJoe (Curate) on Jun 25, 2000 at 23:13 UTC
    • I did notice if you mentioned this but make sure the file you are writing to has Read and Write on it. (gbook.txt). If you do a chmod 755 on the script it will only give the Internet user RX rights to it.

    • Also run your script with a -w where it says #!/usr/bin/perl -w and run it from the command line. Then it will show you any errors that it has with anything that you have done in the system.

    • Try using the CGI.pm (or CGILite.pm)module to get the information that has been posted/sent by the HTML document. Using a module will clean up your code and make it more understandable to debug.


    --BigJoe

    PS I actually tried to bring up gbook.txt as it shows in your script and there is none accessable to the Internet User in that location.
      Joe I am so sorry to have wasted your time. I tried to get back quickly before anyone replied to avoid this but I was too late! Thank you so much for your help - but the missing 'x-factor' was that I am a complete prat. I had not substituted the full directory path for the 'usr' bit in the first line of my script. What an idiot. It is quite normal that the guestbook.txt was empty as I haven't yet been able to write a message to it. Once again - I am really sorry. I'm going away now quietly to crawl into a hole and hide! Perhaps I'll take up knitting Anmaco