Go Back   HostGator Peer Support Forums > Public Forums > Pre-Sales Questions

Notices

Reply
 
Thread Tools
  #1  
Old 07-06-2006, 07:08 PM
Antistrategos Antistrategos is offline
Hatchling Croc
 
Join Date: Jul 2006
Posts: 4
Default Requesting Python/PERL CGI assistance.

My humblest apologize for a potentially lengthy and embarassing request. I work as a computer programmer, yet I have just recently taken an interest in running a website and playing with code online. I must admit, I am completely and utterly lost on several matters, one of which concerns Python CGI.

That is, I know what I want to be able to do- I want to be able to take user input via an HTML form, run it through a Python script, and output information on my website. I'd have thought it would be fairly simple- but after spending countless hours studying countless manuals online, I simply cannot get it to work.

While I'd appreciate a complete tutorial to how I might do so, I'll try to sum up what I've managed to learn so far- and in all honesty, it isn't much. Furthermore, if someone instead knows how to handle such a request by explaining it in PERL, I do not imagine the two are overly different- I'll certainly make due. =)

My "script" consists of the following, in python:

Quote:
#!/usr/bin/python
import sys
try:
import cgitb
cgitb.enable()
except ImportError:
sys.stderr = sys.stdout
def cgiprint(inline=''):
sys.stdout.write(inline)
sys.stdout.write('\r\n')
sys.stdout.flush()
contentheader = 'Content-Type: text/html'
thepage = '''<html><head>
<title>%s</title>
</head><body>
%s
</body></html>
'''
h1 = '<h1>%s</h1>'
if __name__ == '__main__':
cgiprint(contentheader) # content header
cgiprint() # finish headers with blank line
title = 'Hello World'
headline = h1 % 'Hello World'
print thepage % (title, headline)
It is a blatant rip off of a Guide, of course, but I am simply trying all that I can. So far, I have tried:

1) Saving it within a CGI-BIN as a .cgi, .py, .pyc
2) Making all the permissions I can via SMARTFTP 755 or 777.
3) Repeating steps in the SCGI-BIN.

When my HTML form points to the script within the CGI-BIN, I receive the 500 Error. When my HTML form points to the script in the SCGI-BIN, I simply see my code written out again, rather than it running anything.

I'm sure it is a newbie problem- but that doesn't mean you won't make me a dozens of others your willing worshippers if you assist.

Thanks,
Antistrategos
Reply With Quote
  #2  
Old 07-06-2006, 07:10 PM
Antistrategos Antistrategos is offline
Hatchling Croc
 
Join Date: Jul 2006
Posts: 4
Default Re: Requesting Python/PERL CGI assistance.

In retrospect, that is a silly script to post here. It's one of many I've tried- I'd be happy if I could just run a script that printed "Hello" at this point.
Reply With Quote
  #3  
Old 07-06-2006, 09:55 PM
Serra's Avatar
Serra Serra is offline
Veteran Croc
 
Join Date: Feb 2005
Location: Orange Park, FL
Posts: 5,067
Default Re: Requesting Python/PERL CGI assistance.

Start with the perldigger script. Once you get that working, then move on to other scripts.
__________________
Six stages of Dedi Ownership

Fashionable broken link
image included
Reply With Quote
  #4  
Old 07-06-2006, 10:25 PM
Antistrategos Antistrategos is offline
Hatchling Croc
 
Join Date: Jul 2006
Posts: 4
Default Re: Requesting Python/PERL CGI assistance.

I suppose it is only natural that your simple suggestion worked like a charm, and I am left with the expected feeling of embarassment. =)

Thank you for your quick response and assistance, I'm definitely impressed with Host Gator so far, and don't imagine I need look anywhere else for web hosting. I salute you!

-Antistrategos.

(Apologies for the spelling errors in the original post, I am quite used to having the ability to edit as soon as I submit.)
Reply With Quote
  #5  
Old 07-08-2006, 08:05 AM
Serra's Avatar
Serra Serra is offline
Veteran Croc
 
Join Date: Feb 2005
Location: Orange Park, FL
Posts: 5,067
Default Re: Requesting Python/PERL CGI assistance.

Don't worry, some times it take a guy who has sat there for HOURS working the same stupid problem to come up with the answer he found in the end.

The good news is that HG is converting to PHPSuExec, so Perl isn't as needed as it once was.
__________________
Six stages of Dedi Ownership

Fashionable broken link
image included
Reply With Quote
  #6  
Old 07-19-2006, 06:57 PM
The Angel The Angel is offline
Hatchling Croc
 
Join Date: Mar 2006
Posts: 5
Default Re: Requesting Python/PERL CGI assistance.

I had a similar problem not to long ago. You need to add an extra carriage return at the end of the script, preferably with a compatible editor. I upload my Python and Perl scripts then open them with the CPanel HTML editor to add the return.

Also make sure that your envelope is correct. HG's is a bit different from the standard so you may want to check with tech support.

Quote:
#!/usr/bin/python
Reply With Quote
Reply

Bookmarks

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

All times are GMT -6. The time now is 08:47 AM.

 
Forum SEO by Zoints