MystikGotan has asked for the wisdom of the Perl Monks concerning the following question:
Maybe you could try this? I made a simple script, only printing text to see if it works, but it doesn't. Other scripts do, however. On that script (just the printing one), I changed to Perl interpreter path, but....
#!usr/bin/perl -w use warnings; # use Module warnings (for better error checking) use CGI; # use Module CGI (enhanced CGI functions) use strict; # stricter acces for subs, references and vars without sco +pe (nice for error trapping) use Fcntl; # Module used for system operations (mostly UNIX). This is +one I need for flock() use vars qw($q); print "Content-type: text/html\n\n"; # To let the CGI Interface run, d +eclare content-type # SET VARIABLES !!! # $use_flock = 0; # set to 0 if you don't use flock(), otherwise use 1 $q = new CGI; # Parameters: (we will let CGI.PM handle form-processing) my $query_name = $q->param('name'); my $query_email = $q->param('email'); my $query_msg = $q->param('message'); # prepare file acces mkdir('messages', 0777); # make directory called message, permissions +set to ALL ACCES # CALL SUBROUTINES # &open_file; &write_file; # END CALL SUBROUTINES # sub open_file { my (@filecontents); opendir(MSGDIR, "/messages"); @files = readdir(MSGDIR); close(MSGDIR); foreach $file (@files) { open(OPENFILE, "/messages/$file"); if ($use_flock == 1) { flock(OPENFILE, LOCK_NB); } # use flock() when value set to 1 @filecontents = <OPENFILE>; if ($use_flock == 1) { flock(OPENFILE, LOCK_UN); } # don't use flock() when value set to 0 close(OPENFILE); print<<__HTML__; foreach $fcontent (@filecontents) { print($fcontent); } __HTML__ } } # end open_file sub write_file { &HTML; my ($writefile) = "msg" . $$ . ".txt"; # construct filename; $ +$ = process ID if (defined($query_name, $query_email, $query_message)) { $def = 1; } else { $def = 0; } if ($def == 1) { open(WRITEFILE, ">$writefile") or die("Can't open $writef +ile. \n Error:\n $!"); print WRITEFILE, $query_name; print WRITEFILE, $query_email; print WRITEFILE, $query_msg; close(WRITEFILE); } else { print("You did not enter any valid input.\n Pleas +e go back to fill them in."); } } # end write_file sub HTML { print<<HTML; <html> <head> <title>Guestbook - Test #0.01 - Beta 0.01</title> </head> <body> <center> <font face="Tahoma"> Please fill in a messsage.<Br><br><br><br> <form method="POST"> <b>Name:</b> <input type="text" value="name"><br> <b>Email:</b> <input type="text" value="email"><br><br> <b>Message:</b> <Br><br><textarea rows="5" cols="25"></textarea><br> <Br><button type="submit">Send Message!</button> </form> </font> <center> </body> </html> HTML; } 1;
Edit by tye, remove PRE tags, add CODE and READMORE tags.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Guestbook Problem - 500 Error [ISE]
by DamnDirtyApe (Curate) on Nov 27, 2002 at 22:17 UTC | |
|
Re: Guestbook Problem - 500 Error [ISE]
by davorg (Chancellor) on Nov 27, 2002 at 22:27 UTC | |
|
Re: Guestbook Problem - 500 Error [ISE]
by bart (Canon) on Nov 28, 2002 at 02:44 UTC | |
|
Re: Guestbook Problem - 500 Error [ISE]
by arrow (Friar) on Nov 28, 2002 at 01:19 UTC |