SunQuest
           Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old March 7th, 2004, 01:33 PM
brrrett brrrett is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 14 brrrett User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
cgi test script to check server

I am having problems implementing a Python script that works on my pc, but get an internal server error or just displays as text on the web server.(The internal Server error says "Premature end of script header" in the error log.

The server is equiped with Python 1.5.2(trying to get them to upgrade) @ #!/usr/lib/python.

http://www.haystar.com/cgi-bin/demreq.py
http://www.haystar.com/scgi-bin/demreq.py

Anybody have a suggestion on a simple test script to see if Python is even kicking off.

Thanks,
Brett

Reply With Quote
  #2  
Old March 7th, 2004, 02:54 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 18 m 50 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
This error happens so often you would have thought more documentation on this error would be around. Anyway what this means is that your program is sending a bad header to Apache.

Make sure you are putting any raw data before you're headers and that there is a blank line after your headers and it should be fine .

Mark.
__________________
programming language development: www.netytan.com Hula


Reply With Quote
  #3  
Old March 7th, 2004, 05:28 PM
brrrett brrrett is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 14 brrrett User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I don't have a header() method in my code. Does this mean it needs one?

I am trying to read up on headers...I don't exactly know what they are and what purpose they serve.

Reply With Quote
  #4  
Old March 7th, 2004, 06:06 PM
MasterChief MasterChief is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Virginia
Posts: 491 MasterChief User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 47 m 47 sec
Reputation Power: 6
Send a message via AIM to MasterChief Send a message via MSN to MasterChief
Try putting

Code:
print 'Content-Type: text/html\n'


after

Code:
#/usr/lib/python

Reply With Quote
  #5  
Old March 7th, 2004, 07:14 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 18 m 50 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
No, you don't need a header method(). infact this has nothing to do with Python as such. In any CGI program you send headers to the server and the browser so that the software knows what to do i.e. whether the document is html or text. This is done by printing a string that the software understands...

Code:
#!/usr/bin/env python

print 'Content-Type: text/html\n' #Conent type header.
print '<b>Hello Wold</b>'


Will render a html document which says "Hello Wold"

Code:
#!/usr/bin/env python

print 'Content-Type: text/plain\n' #Conent type header.
print '<b>Hello Wold</b>'


will render a plain text document saying "<b>Hello Wold</b>\n"

For more info on this subject check out this thread by roypython.

http://forums.devshed.com/t127603/s.html

or search this forum .

Mark.

Reply With Quote
  #6  
Old March 7th, 2004, 07:39 PM
brrrett brrrett is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 14 brrrett User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
OK. had that. Thanks for the info on headers. I really want to use Python and learn it more, but I don't know if I will sense I got a Perl script to work with the form in 30 minutes.

Reply With Quote
  #7  
Old March 7th, 2004, 08:03 PM
MasterChief MasterChief is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Virginia
Posts: 491 MasterChief User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 47 m 47 sec
Reputation Power: 6
Send a message via AIM to MasterChief Send a message via MSN to MasterChief
Python is way better. You're just starting to learn, that's all. Take care!

Reply With Quote
  #8  
Old March 8th, 2004, 06:28 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 18 m 50 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Agreeing with chief; as a language Python outshines perl at nearly every turn! In both clarity and power. However perls CGI package is amazing and Python seems to have been left behind in this respect. Chooseing to turn its attention to other aeas .

I'm actually working on my own module to make CGI in python easier but it's still in a beta state.

Mark.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > cgi test script to check server


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway