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 -
#!/usr/bin/perl
-
use CGI':standard';
-
use strict;
-
-
print "Content-type: text/html\n\n";
-
-
#name of the user
-
my $name;
-
#obtaining the name from a cookie
-
$name = cookie('name');
-
-
-
print <<HTML;
-
<html>
-
<head>
-
<title> CPS 530 Assignment 1 </title>
-
<link rel="stylesheet" type="text/css" href="/home/jwong/public_html/assignment1/style.css" />
-
</head>
-
<body>
-
<br><br>
-
<h1> Welcome to Jay\'s photo upload </h1>
-
HTML
-
-
#if there is a user name from the cookie
-
if ($name) {
-
print <<HTML;
-
<p> Pleased to see you\'ve returned, $name</p><br><br>
-
<a href="http://www.scs.ryerson.ca/~jwong/assignment1/a1.html"><img src="nextbutton.gif" alt="next page" /></a>
-
</body>
-
</html>
-
HTML
-
}
-
-
#if this is a new vistior
-
else {
-
print <<HTML;
-
<p> This must be your first time here, please tell me your name </p>
-
<p> Name: <form action="cookie.cgi" method="post"><input type="text" name="name"><input type="submit" value="done"></form></p>
-
</body>
-
</html>
-
HTML
-
}
-
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
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
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.
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
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.)
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: -
dos2unix filename.cgi filename.cgi
-
Otherwise, all it will do is output the cleaned up text to the screen for you to see.
Regards,
Jeff
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: -
dos2unix filename.cgi filename.cgi
-
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: - patty Programming in Perl $ man dos2unix
-
Reformatting page. Please Wait... done
-
When called without parameters, the utility reads from the stan-
-
dard input, transforming CR/LF pairs into an LF character and
-
writing it to the standard output. If there's at least one
-
filename specified, the operands are processed in command line
-
order, reading from the files specified and overwriting them with
-
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.
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
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.
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.
eWish 971
Recognized Expert Contributor
Another suggestion for you to consider.
--Kevin
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).
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.
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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.
...
|
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...
|
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,...
| |
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...
|
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...
|
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,...
|
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...
|
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...
|
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 ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |