I'm just not cut out for web programming, I guess :)

J

John Salerno

Ok, I've tinkered with this thing for a while, and I keep fixing little
problems, but I always get a 500 Internal Server error when I go to this
site:

I don't necessarily even want help just yet, I'd like to figure it out
myself, but can someone at least tell me why I'm not getting helpful
feedback from the cgitb module? Am I using it wrong? The webpage just
displays the internal server error.

Thanks.



import cryptogen
import cgitb; cgitb.enable()

quote_file = open('quotes.txt')
quote = quote_file.readline().strip()
quote_file.close()

print '''content-type: text/html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html lang="en-us">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title></title>
</head>

<body><form action="cryptopage.py">'''

quote = cryptogen.convert_quote(quote)
for word in quote[0].split(' '):
word_len = len(word)
print '<input type="text" name="%s" size="%d">' % (word, word_len)

print '<input type="submit" value="Submit"></form></body></html>'
 
D

Dan M

Ok, I've tinkered with this thing for a while, and I keep fixing little
problems, but I always get a 500 Internal Server error when I go to this
site:

I don't necessarily even want help just yet, I'd like to figure it out
myself, but can someone at least tell me why I'm not getting helpful
feedback from the cgitb module? Am I using it wrong? The webpage just
displays the internal server error.

Thanks.

Having to debug web scripts on hosts where you don't have shell access can
be a major pain. If you are referring to the wrong path in the "bang-path"
line, you'd get that error non-message. Likewise if the file permissions
were wrong.
 
P

Paul McNett

John said:
Ok, I've tinkered with this thing for a while, and I keep fixing little
problems, but I always get a 500 Internal Server error when I go to this
site:

I don't necessarily even want help just yet, I'd like to figure it out
myself, but can someone at least tell me why I'm not getting helpful
feedback from the cgitb module? Am I using it wrong? The webpage just
displays the internal server error.

Thanks.



import cryptogen
import cgitb; cgitb.enable()

quote_file = open('quotes.txt')
quote = quote_file.readline().strip()
quote_file.close()

print '''content-type: text/html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html lang="en-us">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title></title>
</head>

<body><form action="cryptopage.py">'''

quote = cryptogen.convert_quote(quote)
for word in quote[0].split(' '):
word_len = len(word)
print '<input type="text" name="%s" size="%d">' % (word, word_len)

print '<input type="submit" value="Submit"></form></body></html>'

Are you sure the python that the web server runs has the cryptogen
module available? Have you set the execute bit on your script? What's
the output in your web server error log?
 
J

John Salerno

Paul said:
Are you sure the python that the web server runs has the cryptogen
module available?

Yes, this module and the cryptogen module (and the quotes.txt file) are
all in the same directory on the server.
Have you set the execute bit on your script?

Yes, I have them both set to 755.
What's
the output in your web server error log?

Well, I can't seem to find any error logs. In my logs folder, there are
files called 'access.log' and 'ftp.log', but nothing that looks like an
error log.
 
J

John Salerno

John said:
Yes, this module and the cryptogen module (and the quotes.txt file) are
all in the same directory on the server.


Yes, I have them both set to 755.


Well, I can't seem to find any error logs. In my logs folder, there are
files called 'access.log' and 'ftp.log', but nothing that looks like an
error log.

Hmmm, looks like they don't do error logging:



Creating own error logs for debugging php scripts.

Since we dont provide access to Apache error logs on shared hosting
packages for
technical reasons, you can create your own error logs for debugging PHP
Scripts.

Please insert the following code in your PHP script (or create separate
file and
and add the code in it. Include the file using "include()")


error_reporting(0);
$old_error_handler = set_error_handler("userErrorHandler");

function userErrorHandler ($errno, $errmsg, $filename, $linenum,
$vars)
{
$time=date("d M Y H:i:s");
// Get the error type from the error number
$errortype = array (1 => "Error",
2 => "Warning",
4 => "Parsing Error",
8 => "Notice",
16 => "Core Error",
32 => "Core Warning",
64 => "Compile Error",
128 => "Compile Warning",
256 => "User Error",
512 => "User Warning",
1024 => "User Notice");
$errlevel=$errortype[$errno];

//Write error to log file (CSV format)
$errfile=fopen("errors.csv","a");
fputs($errfile,"\"$time\",\"$filename:
$linenum\",\"($errlevel) $errmsg\"\r\n");
fclose($errfile);

if($errno!=2 && $errno!=8) {
//Terminate script if fatal errror
die("A fatal error has occured. Script execution has been
aborted");
}
}
 
J

John Salerno

John said:
Ok, I've tinkered with this thing for a while, and I keep fixing little
problems, but I always get a 500 Internal Server error when I go to this
site:

Ok, in case anyone is curious, I figure out my problems. Let me first
give you a hint: my web server is running Python 2.2.1

On to the fun:

1. cgi traceback was not being displayed because the problem was with
the first import statement; i moved import cgitb above it and finally
got the nice-looking traceback info

2. i was importing itertools, which of course is not standard

3. i was using the built-in set(), which is new in 2.4

4. i tried to import sets, but that was new in 2.3

So the bottom line is I'm kind of screwed until I can get 1and1 to
update their Python! :) But at least I figured out some stuff.
 
B

Ben Finney

John Salerno said:
So the bottom line is I'm kind of screwed until I can get 1and1 to
update their Python! :) But at least I figured out some stuff.

You should also look around for other hosting options. A web hosting
provider that doesn't give access to server logs isn't providing good
service.
 
D

Dennis Lee Bieber

import cryptogen
import cgitb; cgitb.enable()
Swap the order of those -- as it stands now, if the first import
fails, you won't get a traceback because they haven't been enabled yet.

I'm guessing "cryptogen" is one of your modules. You may need to add
the cgi-bin directory to the Python import search path -- it may be
looking in the Python Lib directory and not finding it.
--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top