WebFaction
Community site: login faq

Hi all,

I'm trying to learn Python, and also to throw simple (very simple) scripts up on my site to tinker with. A friend gave me this as a good demo script to see if it works in general, starting with something called the "shebang":

#!/usr/bin/python
print "Content-Type: text/html; charset=utf-8\n"
print ""
print "Hello, world!"
print ""

Nothing doing -- I suspect because I've put hello.py inside a folder inside my main site, and I'm trying to open it by going to www.foo.com/pythontests/hello.py and seeing if it works. Do I need a different path than usr/bin/python for this to work? Is there something else I'm missing?

asked 20 Feb '12, 12:01

mattshepherd
4541830
accept rate: 0%


There's nothing wrong with using /usr/bin/python.

If you're seeing a 500 error when accessing the script above via the web, then it's probably a permissions problem. Try setting the permissions on the script and on its parent directory to 711.

We have some more CGI tips in our old blog at: Debugging tips for your CGI scripts

Hope that helps!

permanent link

answered 20 Feb '12, 14:39

seanf
12.2k41836
accept rate: 37%

Awesome! Thanks for that, and for the debugging link. I'm sure it'll come in handy!

(24 Feb '12, 11:41) mattshepherd
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×337
×31
×19

question asked: 20 Feb '12, 12:01

question was seen: 3,151 times

last updated: 24 Feb '12, 11:56

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM