very basic (error 500 internal server error)

They have: 33 posts

Joined: Mar 2001

ok, i am a comp sci major(soph) so i do know about programming, however i am new to scripting.

i got a script from someone and editted it, perl.

when i try to use it, it gives the big 500 Smiling

my network admin. fixed it once and it worked, but it seems when i upload it to work on it, it doesn't work any more and i don't want to bother them any more than i have to, i am competant and can learn.

do i need to play with the rwx stuff?

i have read about scripts and am getting tired of checking over my code again and again, it can't be the script, it must just be me not knowing how to exactly put it in my cgi-bin folder correctly.

my net admin just fixed it, somehow, and told me it works, so that doesn't learn me anything:)

hope someone can explain the basics to me!!!

thanks

Nathan Bell
NateBell.com

They have: 850 posts

Joined: Jul 1999

Hello, and welcome to the forums!

Here are a few pointers to try and help troubleshoot your problems:

1. Is the path to perl correct? With most hosts, the path to perl is /usr/bin/perl or/and /usr/bin/local/perl. If you are unsure, telnet to your host and type 'locate perl'.

2. Are the scripts chmod correctly (the rwx stuff)? Your scripts should usually be chmod to 755, or even 777.

3. Make sure you upload the scripts in Ascii rather than Binary.

4. Try adding the code CGI::Carp qw(fatalsToBrowser); to your script (generally place it close to the top, but after the first line). This will spit out any errors your script is creating.

Hope that helps.

They have: 33 posts

Joined: Mar 2001

for some reason i couldn't telnet in. i tried the line of code you gave me, but that didn't seem to help after i uploaded it, it was working before, but for some reason when i try to upload it with changes it just goes back to giving me a 500 error.

i am just frustrated because i don't know what the problem is, and it seems to be finicky at best Sad

thanks, any more help would be appreciated.

Nathan Bell
NateBell.com

They have: 33 posts

Joined: Mar 2001

print "\n";

is the semi-colon causing the problem?

how could i just make the script jump them to natebel.com after it is done?

They have: 33 posts

Joined: Mar 2001

#!/usr/bin/perl

##############################################################################
# Guestbook Version 2.3.1 #
# Copyright 1996 Matt Wright [email protected] #
# Created 4/21/95 Last Modified 03/01/01 (natebell.com) #
# Scripts Archive at: http://www.worldwidemart.com/scripts/ #
##############################################################################
# COPYRIGHT NOTICE #
# Copyright 1996 Matthew M. Wright All Rights Reserved. #
# #
# Guestbook may be used and modified free of charge by anyone so long as #
# this copyright notice and the comments above remain intact. By using this #
# code you agree to indemnify Matthew M. Wright from any liability that #
# might arise from it's use. #
# #
# Selling the code for this program without prior written consent is #
# expressly forbidden. In other words, please ask first before you try and #
# make money off of my program. #
# #
# Obtain permission before redistributing this software over the Internet or #
# in any other medium. In all cases copyright and header must remain intact.#
##############################################################################
# Set Variables

CGI::Carp qw(fatalsToBrowser);

# This file is where the quotes will be sent to.
$guestbookurl = "http://www.natebell.com/viewquotes.html";
$guestbookreal = "/home/natebell/natebell-www/viewquotes.html";

# where i can see a short list of the quotes and any errors.
$guestlog = "http://www.natebell.com/quotelog.html";

# where the cgi script lives.
$cgiurl = "http://www.natebell.com/cgi-bin/submit.cgi";

# where the date is stored on the server.
$date_command = "/usr/bin/date";

# Set Your Options:
$mail = 1; # 1 = Yes; 0 = No
$uselog = 1; # 1 = Yes; 0 = No
$linkmail = 1; # 1 = Yes; 0 = No
$separator = 1; # 1 = ; 0 =
$redirection = 0; # 1 = Yes; 0 = No
$entry_order = 1; # 1 = Newest entries added first;
# 0 = Newest Entries added last.
$remote_mail = 1; # 1 = Yes; 0 = No
$allow_html = 1; # 1 = Yes; 0 = No
$line_breaks = 0; # 1 = Yes; 0 = No

# If you answered 1 to $mail or $remote_mail you will need to fill out
# these variables below:
$mailprog = '/usr/lib/sendmail';
$recipient = '[email protected]';

# Done
##############################################################################

# Get the Date for Entry
$date = `$date_command +"%A, %B %d, %Y at %T (%Z)"`; chop($date);
$shortdate = `$date_command +"%D %T %Z"`; chop($shortdate);

# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

# Split the name-value pairs
@pairs = split(/&/, $buffer);

foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);

# Un-Webify plus signs and %-encoding
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s///g;

if ($allow_html != 1) {
$value =~ s/<([^>]|\n)*>//g;
}

$FORM{$name} = $value;
}

# Print the Blank Response Subroutines
&no_comments unless $FORM{'comments'};
&no_name unless $FORM{'realname'};

# Begin the Editing of the Guestbook File
open (FILE,"$guestbookreal") || die "Can't Open $guestbookreal: $!\n";
@LINES=;
close(FILE);
$SIZE=@LINES;

# Open Link File to Output
open (GUEST,">$guestbookreal") || die "Can't Open $guestbookreal: $!\n";

for ($i=0;$i<=$SIZE;$i++) {
$_=$LINES[$i];
if (//) {

if ($entry_order eq '1') {
print GUEST "\n";
}

if ($line_breaks == 1) {
$FORM{'comments'} =~ s/\cM\n/\n/g;
}

print GUEST "$FORM{'comments'}\n";

if ($FORM{'url'}) {
print GUEST "$FORM{'realname'}";
}
else {
print GUEST "$FORM{'realname'}";
}

if ( $FORM{'username'} ){
if ($linkmail eq '1') {
print GUEST " \<";
print GUEST "$FORM{'username'}
\>";
}
else {
print GUEST " <$FORM{'username'}>";
}
}

print GUEST "\n";

if ( $FORM{'city'} ){
print GUEST "$FORM{'city'},";
}

if ( $FORM{'state'} ){
print GUEST " $FORM{'state'}";
}

if ( $FORM{'country'} ){
print GUEST " $FORM{'country'}";
}

if ($separator eq '1') {
print GUEST " - $date\n\n";
}
else {
print GUEST " - $date\n\n";
}

if ($entry_order eq '0') {
print GUEST "\n";
}

}
else {
print GUEST $_;
}
}

close (GUEST);

# Log The Entry

if ($uselog eq '1') {
&log('entry');
}

#########
# Options

# Mail Option
if ($mail eq '1') {
open (MAIL, "|$mailprog $recipient") || die "Can't open $mailprog!\n";

print MAIL "Reply-to: $FORM{'username'} ($FORM{'realname'})\n";
print MAIL "From: $FORM{'username'} ($FORM{'realname'})\n";
print MAIL "Subject: Quotes\n\n";
print MAIL "You have a new entry to your quotes:\n\n";
print MAIL "------------------------------------------------------\n";
print MAIL "$FORM{'comments'}\n";
print MAIL "$FORM{'realname'}";

if ( $FORM{'username'} ){
print MAIL " <$FORM{'username'}>";
}

print MAIL "\n";

if ( $FORM{'city'} ){
print MAIL "$FORM{'city'},";
}

if ( $FORM{'state'} ){
print MAIL " $FORM{'state'}";
}

if ( $FORM{'country'} ){
print MAIL " $FORM{'country'}";
}

print MAIL " - $date\n";
print MAIL "------------------------------------------------------\n";

close (MAIL);
}

if ($remote_mail eq '1' && $FORM{'username'}) {
open (MAIL, "|$mailprog -t") || die "Can't open $mailprog!\n";

print MAIL "To: $FORM{'username'}\n";
print MAIL "From: $recipient\n";
print MAIL "Subject: Thank you for submitting a quote!\n\n";
print MAIL "Thank you for adding to my list of quotes and/or sending me comments.\n\n";
print MAIL "I will review your submition.\n\n";
print MAIL "------------------------------------------------------\n";
print MAIL "$FORM{'comments'}\n";
print MAIL "$FORM{'realname'}";

if ( $FORM{'username'} ){
print MAIL " <$FORM{'username'}>";
}

print MAIL "\n";

if ( $FORM{'city'} ){
print MAIL "$FORM{'city'},";
}

if ( $FORM{'state'} ){
print MAIL " $FORM{'state'}";
}

if ( $FORM{'country'} ){
print MAIL " $FORM{'country'}";
}

print MAIL " - $date\n";
print MAIL "------------------------------------------------------\n";
print MAIL "NateBell.com\n";

close (MAIL);
}

# Print Out Initial Output Location Heading
if ($redirection eq '1') {
print "Location: $guestbookurl\n\n";
}
else {
&no_redirection;
}

#######################
# Subroutines

sub no_comments {
print "Content-type: text/html\n\n";
print "No Comments\n";
print "Your Comments appear to be blank\n";
print "The comment section in the guestbook fillout form appears\n";
print "to be blank and therefore the submission was not\n";
print "added. Please enter your comments below.\n";
print "\n";
print "Your Name:\n";
print "E-Mail: \n";
print "City: , State: Country: \n";
print "Comments:\n";
print "\n";
print " * \n";
print "Return to the Guestbook.";
print "\n\n";

# Log The Error
if ($uselog eq '1') {
&log('no_comments');
}

exit;
}

sub no_name {
print "Content-type: text/html\n\n";
print "No Name\n";
print "Your Name appears to be blank\n";
print "The Name Section in the form appears to\n";
print "be blank and therefore your entry was not\n";
print "added. Please add your name in the blank below.\n";
print "\n";
print "Your Name:\n";
print "E-Mail: \n";
print "City: , State: Country: \n";
print "Your entry has been retained.\n";
print "\n";
print " * \n";
print "Return to the Guestbook.";
print "\n\n";

# Log The Error
if ($uselog eq '1') {
&log('no_name');
}

exit;
}

# Log the Entry or Error
sub log {
$log_type = $_[0];
open (LOG, ">>$guestlog");
if ($log_type eq 'entry') {
print LOG "$ENV{'REMOTE_HOST'} - [$shortdate]\n";
}
elsif ($log_type eq 'no_name') {
print LOG "$ENV{'REMOTE_HOST'} - [$shortdate] - ERR: No Name\n";
}
elsif ($log_type eq 'no_comments') {
print LOG "$ENV{'REMOTE_HOST'} - [$shortdate] - ERR: No ";
print LOG "Comments\n";
}
}

# Redirection Option
sub no_redirection {

# Print Beginning of HTML
print "Content-Type: text/html\n\n";
print "Thank You\n";
print "\n";
print "\n";
print "Thank You For Adding A Quote.\n";

# Print Response
#print "Thank you for adding a quote. Your entry has\n";
#print "been sent for review.\n";
#print "Here is what you submitted:\n";
#print "$FORM{'comments'}\n";

#if ($FORM{'url'}) {
# print "$FORM{'realname'}";
#}
#else {
# print "$FORM{'realname'}";
#}

#if ( $FORM{'username'} ){
# if ($linkmail eq '1') {
# print " <";
# print "$FORM{'username'}
>";
# }
# else {
# print " <$FORM{'username'}>";
# }
#}

#print "\n";

#if ( $FORM{'city'} ){
# print "$FORM{'city'},";
#}

#if ( $FORM{'state'} ){
# print " $FORM{'state'}";
#}

#if ( $FORM{'country'} ){
# print " $FORM{'country'}";
#}

#print " - $date\n";

# Print End of HTML
print "\n";
print "NateBell.com\n";
print "\n";

exit;
}

if you see anything wrong with it tell me, thanks

Nathan Bell
NateBell.com

They have: 850 posts

Joined: Jul 1999

The best thing to do is to ask your network admin how he/she fixed it last time.

They have: 33 posts

Joined: Mar 2001

it is working now, i am embarrassed to say, but i was transferring them in binary!!!!!!!!!!

oh well, lesson to be learned, when you use different computers to transfer, make sure all of them are on the same settings when transferring. that explains the sporatic results i was getting, but i think i will keep looking on this forum i learned a lot.

thanks,

Nate

Nathan Bell
NateBell.com

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.