Solved

500 internal server error

Posted on 2009-03-31
9
178 Views
Last Modified: 2014-06-27
I have 2 pieces of code that i need to be debugged and ive ran them both through a debugger, but I get an internal server error everytime. I followed the instructions and searched around and everywhere says that I need to set permissions and put the files in the right folder on the server and I do have all that right, yet I still get this error. Anyone know any ideas why I still get this error? here's my code:

<html>
<head><title>Project 7</title>
<link rel = "stylesheet" type = "text/css" href = "style.css" />
</head>
<body id = "p7">
<center>
   <h3>Enter story here</h3>
 
   <form action = "http://lab.cs.siu.edu/~dnaraine/cgi-bin/story2.cgi" method = "post">
 
   <textarea name = "name" rows="20"  cols="40"></textarea>
 
   <p>
   <input type = "submit" value= "Submit Form"/>
   <input type = "reset" value= "Reset"/>
   </p>
   </form>
   
  
 
 
</center>
</body>
</html>
 
 
 
AND
 
 
 
 
 
 
 
 
#!/usr/local/bin/perl
 
use CGI ":standard";
use Fcntl qw(:DEFAULT :flock);
 
sub error {
    print start_html();
    print "Error - input/output error <br/>";
    print end_html();
    exit(1);
}
 
 
      my($str) = (param("name"));
 
 
 
      $topword = "story.txt";
 
  
      open($topword, "a+") or die("Error - file cannot be opened");
      print($topword, $str);
      close($topword);
 
            
      print("<br /> Your story is about $topWord<br /><br />");

Open in new window

0
Comment
Question by:RAXMAN
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
9 Comments
 
LVL 48

Expert Comment

by:Tintin
ID: 24035439
Need to see your code, not the HTML.

0
 
LVL 2

Author Comment

by:RAXMAN
ID: 24035573
scroll down more
0
 
LVL 39

Accepted Solution

by:
Adam314 earned 500 total points
ID: 24036014
You can get the details about the errors from the error log.

In this case, it looks like it's because you aren't printing a HTTP header.  The header needs to be the first thing your program displays.  To print a header, add this line before anything else is printed:
    print header();

Another thing that could cause it is if your perl isn't /usr/local/bin/perl?  You can find out by typing "which perl" at a prompt.

0
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
LVL 2

Author Comment

by:RAXMAN
ID: 24043584
Ive tried to make the code more basic. I cant see the error log because I dont own the server. The school does.

My code is actually more complicated than this code im posting, but im trying to get it working period. Ive tried MORE simpler codes by the teacher and his works, but not mine. So I dont get why my code is wrong.
#!/usr/local/bin/perl
 
use CGI ":standard";
use Fcntl qw(:DEFAULT :flock);
 
      my($str) = (param("name"));
 
      print header();
 
      $topword = "story.txt";
 
  
      open($topword, "a+") or die("Error - file cannot be opened");
      print($topword, $str);
      close($topword);
 
            
      print("<br /> Your story is about $topWord<br /><br />");
 
    
  

Open in new window

0
 
LVL 39

Expert Comment

by:Adam314
ID: 24043621
If what you posted isn't working, but simpler code does, the problem could be the open statement.  It is likely that the web server user does not have permission to open the file for writing - so your program dies.  If you add this to the top of your script, you'll get a more detailed error message:
    use CGI::Carp 'fatalsToBrowser';
0
 
LVL 2

Author Comment

by:RAXMAN
ID: 24043747
yea you're right it says it cannot open the file in line 16 which is story.txt

how do i fix that? the file permissions are: rwxr-xr-x
0
 
LVL 39

Assisted Solution

by:Adam314
Adam314 earned 500 total points
ID: 24044006
Well, if you want to allow the web server to open it, change it to either:
    If the group is the web server user, and it's not exectuable: 664 (rw-rw-r--)
    If the group is the web server user, and it is exectuable: 775 (rwxrwxr-x)
    If the group is not the web server user, and it's not exectuable: 666 (rw-rw-rw-)
    If the group is not the web server user, and it is exectuable: 777 (rwxrwxrwx)

So, because it looks like a non-executable, and the group is probably not the webserver, use 666.  Note that doing this will allow anyone to modify that file though.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need script to search multiple files in one drive 13 58
Convert .csv to tab delimited text 11 50
Powershell Exchange mailboxsizes 3 49
Review of the nodejs code 1 38
In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question