473,509 Members | 7,333 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

why is my site giving me a 500 error?

2 New Member
Im a student of ryerson university, Im trying to create a simple website for my assignment and Im getting a 500 internal server error

my code compiles and doesnt seem to have any syntax errors but I cant seem to figure out what is wrong with it, any help will be great, here is the code I have so far
Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2. use CGI':standard';
  3. use strict;
  4.  
  5. print "Content-type: text/html\n\n";
  6.  
  7. #name of the user
  8. my $name; 
  9. #obtaining the name from a cookie
  10. $name = cookie('name'); 
  11.  
  12.  
  13. print <<HTML;
  14.    <html>
  15.    <head>
  16.       <title> CPS 530 Assignment 1 </title>
  17.       <link rel="stylesheet" type="text/css" href="/home/jwong/public_html/assignment1/style.css" />
  18.    </head>
  19.    <body>
  20.    <br><br>
  21.    <h1> Welcome to Jay\'s photo upload </h1>
  22. HTML
  23.  
  24. #if there is a user name from the cookie
  25. if ($name) {
  26.    print <<HTML;
  27.          <p> Pleased to see you\'ve returned, $name</p><br><br>
  28.          <a href="http://www.scs.ryerson.ca/~jwong/assignment1/a1.html"><img src="nextbutton.gif" alt="next page" /></a>
  29.       </body>
  30.       </html>
  31. HTML
  32. }
  33.  
  34. #if this is a new vistior
  35. else {
  36.    print <<HTML;
  37.          <p> This must be your first time here, please tell me your name </p>
  38.          <p> Name: <form action="cookie.cgi" method="post"><input type="text" name="name"><input type="submit" value="done"></form></p>
  39.       </body>
  40.       </html>
  41. HTML
  42. }
  43.  
Nov 10 '08 #1
13 1687
KevinADC
4,059 Recognized Expert Specialist
The code looks like it should run OK, so something else is wrong. Some possibilities:

the shebang line is wrong
not uploaded in ASCII mode
permissions not correct
Nov 10 '08 #2
DarkenDragon
2 New Member
The code looks like it should run OK, so something else is wrong. Some possibilities:

the shebang line is wrong
not uploaded in ASCII mode
permissions not correct
well the shebang line is pretty much a copy paste job from my professor's notes, and im not sure what you mean by uploading in ascii mode, if you can give me a simple walkthrough on what you mean there, that would be great, (dont think I saw much on that on the lecture slides) and as for permissions, I think I did it right, the cgi-bin folder is set to 711, and the cgi files are set to 644 and i've tried 755. i've even tried it as 777 just as a test and still ended up with the same results

so im guessing the ascii mode portion is what it could be since I've never tested that. i'll just need some kinda guide through how I would test this
Nov 10 '08 #3
KevinADC
4,059 Recognized Expert Specialist
When you transfer the perl script from your computer to the server using an FTP program, you can transfer in ASCII (text files) or binary (images and executables) mode. Read the help files of the FTP application you are using to detemine how to change the transfer mode.

Almost all FTP applications will change the line endings when a file is transferred in ASCII (or text) mode from the local line endings to the line endings of the remote server. For example, if you write the perl program on Windows the line endings are \r\n and if you tranfer that to a Unix server the script would not work because of the carraige returns (\r) but if you use an FTP application almost all of them know to change the line endings to whatever ther remote servers operating system uses, \n for Unix.

Some, not many, editors also allow you to save a file with line endings of many operating systems. You can check your editor to see if there is an option to save as Unix or Linux or whatever.
Nov 10 '08 #4
Ganon11
3,652 Recognized Expert Specialist
If you're porting from a Windows environment to a Linux environment, see if the program dos2unix is available. This changes all the newline characters from Windows newlines to Linux newlines. If you have dos2unix, you can run it on your program as follows:

dos2unix filename.cgi

Your shebang looks old, try

Expand|Select|Wrap|Line Numbers
  1. #!usr/bin/env perl
Not sure what the octal code is for this, but the folder containing your .cgi file should give read and execute permission to 'others', i.e.

chmod o+rx .

Your cgi file itself should have all permissions for user and no other permissions:

chmod 700 filename.cgi

(NOTE: This is all adapted from the course I took a few months ago. The professor taught how to use cgi on our school's servers, so I'm not sure how much of this is universal and how much of this was specific to my classmates and me.)
Nov 10 '08 #5
numberwhun
3,509 Recognized Expert Moderator Specialist

dos2unix filename.cgi
Actually, in the *nix world, the dos2unix command needs two file names, an input and an output. If you have read/write for the file in question, the input and output file names can be the same file name. So, the above would be:

Expand|Select|Wrap|Line Numbers
  1. dos2unix filename.cgi filename.cgi
  2.  
Otherwise, all it will do is output the cleaned up text to the screen for you to see.

Regards,

Jeff
Nov 10 '08 #6
Ganon11
3,652 Recognized Expert Specialist
Actually, in the *nix world, the dos2unix command needs two file names, an input and an output. If you have read/write for the file in question, the input and output file names can be the same file name. So, the above would be:

Expand|Select|Wrap|Line Numbers
  1. dos2unix filename.cgi filename.cgi
  2.  
Otherwise, all it will do is output the cleaned up text to the screen for you to see.

Regards,

Jeff
It doesn't appear you are right...at least, on my machine. Typing:

dos2unix test.pl

does not print anything out to my screen, but in fact executes just fine.

Here's an excerpt from my console:

Expand|Select|Wrap|Line Numbers
  1. patty Programming in Perl $ man dos2unix
  2. Reformatting page.  Please Wait... done
  3. When called without parameters, the utility reads from the  stan-
  4. dard  input,  transforming  CR/LF  pairs into an LF character and
  5. writing it to the standard  output.   If  there's  at  least  one
  6. filename  specified,  the  operands are processed in command line
  7. order, reading from the files specified and overwriting them with
  8. the converted version.
"If there's at least one filename specified, the operands are processed...reading from the files specified and overwriting them with the converted version."

Check your manpage to see if it differs.
Nov 10 '08 #7
numberwhun
3,509 Recognized Expert Moderator Specialist
Its funny. I checked my home system (where I am now) and its the same way you described, but on other systems its how I mentioned. I think the best advice is to read the documentation before using it to be sure which one you are using. :)

Thus, we are both right and I learned that there are different versions.

Regards,

Jeff
Nov 10 '08 #8
Ganon11
3,652 Recognized Expert Specialist
Absurd! We can't both be right! I propose Mortal Kombat to decide who shall prevail.

Back to the real world, reading the manpage would be the preferred solution, I suppose.
Nov 10 '08 #9
KevinADC
4,059 Recognized Expert Specialist
Absurd! We can't both be right! I propose Mortal Kombat to decide who shall prevail.
Duels are against forum guidelines.
Nov 10 '08 #10
eWish
971 Recognized Expert Contributor
Another suggestion for you to consider.

--Kevin
Nov 11 '08 #11
KevinADC
4,059 Recognized Expert Specialist
Another suggestion for you to consider.

--Kevin
Thats a great article by Brian, the only thing he doesn't mention is incorrect line endings (I think).
Nov 11 '08 #12
Ganon11
3,652 Recognized Expert Specialist
He briefly touches on it, but doesn't really explain well how to deal with porting across different OSs.
Nov 11 '08 #13
Icecrack
174 Recognized Expert New Member
Has this user Fixed his problem?

if not another thing he should be looking at is the apache/IIS logs.
Nov 19 '08 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

6
2256
by: Alex Rast | last post by:
First of all, this is not a programming question. I'm a user, not programming in JavaScript. I'm not, however, a novice user or even a power user - I certainly know programming intimately as well...
0
1149
by: sandeep pandit via .NET 247 | last post by:
hello sir, i read your article on URL rewriting in asp.net on msdn.i have also used the same in my project.URL rewriting is working fine in our LAN and on our configured IP but problem is that...
1
1462
by: John | last post by:
Hi We have the html portion of our site in the site root folder on a remote site hosted with a web hosting company. I am now trying to add some asp.net bits to the site but in trying to keep...
5
2495
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant...
4
1227
by: Koen Hoorelbeke | last post by:
Hi there, I'm about to commit suicide :) Since a couple of weeks I have a persistent problem with the performance of my sites (well, actually it's one particular site). For some reason the site...
3
1382
by: Mark C | last post by:
Hi I was in the progress of developing a web site whereby developers can do free online tests on various programming languages. After initial feedback I managed to fix quite a few issues and...
1
1767
by: John Dalberg | last post by:
I converted a working web site project to a web application project and I am getting a bunch of warnings and compile errors. All code using .NET's profile class is giving an error. example...
3
4213
by: =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post by:
When using the Web Site Administration Tool, I get the following error when trying to delete a user in a web application I configured to use membership, roles, and profiles: "An error was...
11
1835
nomad
by: nomad | last post by:
Hello everyone: I have a question to ask you. I'm make a quiz and I get this error Method Not Allowed The requested method POST is not allowed for the URL /quiz/quizaction.phtml. ...
16
1448
by: Nad | last post by:
I have a very large site with valuable information. Is there any way to prevent downloading a large number of articles. Some people want to download the entire site. Any hints or pointers would...
0
7237
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7137
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7416
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5656
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5062
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4732
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1571
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
779
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
443
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.