Connecting Tech Pros Worldwide Help | Site Map

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

John Salerno
Guest
 
Posts: n/a
#1: May 17 '06
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>'
Dan M
Guest
 
Posts: n/a
#2: May 17 '06

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


On Wed, 17 May 2006 20:51:07 +0000, John Salerno wrote:
[color=blue]
> 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.[/color]

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.

Paul McNett
Guest
 
Posts: n/a
#3: May 17 '06

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


John Salerno wrote:[color=blue]
> 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>'[/color]

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?

--
Paul McNett
http://paulmcnett.com
http://dabodev.com

John Salerno
Guest
 
Posts: n/a
#4: May 18 '06

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


Paul McNett wrote:
[color=blue]
> Are you sure the python that the web server runs has the cryptogen
> module available?[/color]

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

Yes, I have them both set to 755.
[color=blue]
> What's
> the output in your web server error log?[/color]

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.
John Salerno
Guest
 
Posts: n/a
#5: May 18 '06

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


John Salerno wrote:[color=blue]
> Paul McNett wrote:
>[color=green]
>> Are you sure the python that the web server runs has the cryptogen
>> module available?[/color]
>
> Yes, this module and the cryptogen module (and the quotes.txt file) are
> all in the same directory on the server.
>[color=green]
>> Have you set the execute bit on your script?[/color]
>
> Yes, I have them both set to 755.
>[color=green]
>> What's
>> the output in your web server error log?[/color]
>
> 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.[/color]

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");
}
}

John Salerno
Guest
 
Posts: n/a
#6: May 18 '06

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


John Salerno wrote:[color=blue]
> 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:[/color]

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.
Ben Finney
Guest
 
Posts: n/a
#7: May 18 '06

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


John Salerno <johnjsal@NOSPAMgmail.com> writes:
[color=blue]
> 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.[/color]

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.

--
\ "I'm beginning to think that life is just one long Yoko Ono |
`\ album; no rhyme or reason, just a lot of incoherent shrieks and |
_o__) then it's over." -- Ian Wolff |
Ben Finney

Closed Thread