x10Hosting Forums

Corporate Free Hosting for the Masses.



Register

Reply
 
LinkBack Thread Tools Display Modes
x10Hosting Member

orange123's Avatar

Join Date: Sep 2008
Posts: 3
Credits: 243
orange123 is on a distinguished road
Quote  
09-26-2008, 06:46 AM
Python (beginner) - how do I get it running, starting from scratch?

Hi,

I am trying to teach myself Python from scratch.
To even get started, I have spent the best part of 5 hours reading tutorials on the web, trying to figure out how to get even one line of Python running on my website. No luck.
So so far, I haven't even tested one line of code.

The tutorials show me how to write script, but (since they assume I am running the script on my PC) not how to get that script to run on my website.

How do I do this?

My file is called myfirstpage.py
Code:
 print 1 + 1
It's just one line, to at least get me started.

I put the file in the directory /cgi-bin/
I then tried to invoke the Python script from a html file, index.html:
Code:
 <html>
<head></head>
<body>
<a href="cgi-bin/myfirstpage.py">Click here to run Python script</a>
</body>
</html>
It doesn't work. When I click the link, it tells me I have a 500 Internal Server Error. Needless to say, I haven't a clue what I'm doing - and I can't teach myself if I can't get even one line to run!

I have looked on other threads.
This inspired me to add one line to my python page:
Code:
#!/usr/bin/python
print 1 + 1
but that didn't help.
Some of the advice given was
"Move file to cgi-bin directory and chmod it 755"

I don't know what 'chmod' means, so I have no idea what 'chmod it 755' means either. Can anyone help me and tell me what to do in layman's terms?

p.s. I'm a complete beginner, the only languages I know are html, xhtml, css and maybe 2 or 3 bits of php.

Thank you very much in advance!!
Reply With Quote
orange123 is offlineReport Post
x10 Sophmore

Scoochi2's Avatar

Join Date: Aug 2008
Posts: 118
Credits: 1,277
Scoochi2 will become famous soon enough
Location: Southport!

Quote  
09-26-2008, 07:38 AM
Re: Python (beginner) - how do I get it running, starting from scratch?

Just Googled it. Read through this site.
Quote:
Some host providers only let you run CGI scripts in a certain directory, often named cgi-bin. In this case all you have to do to run the script is to call it like this:

http://my_server.tld/cgi-bin/my_script.py

The script will have to be made executable by "others". Give it a 755 permission or check the executable boxes if there is a graphical FTP interface.
To change the permissions (chmod) on x10, use the file manager on cpanel, check the box[es] for the file[s] you wish to change, then press the "Change Permissions" icon (it looks like a key, with the text below it). You'll want to check everything except 'write' for group and world. At the bottom, it should say 755 if you do this correctly. If not, just randomly check and uncheck boxes until it says 755.
__________________
If anyone can see it, my post was meant for anyone who reads it. Don't take it personally or think I'm being condescending...

Last edited by Scoochi2; 09-26-2008 at 07:42 AM. Reason: layman's chmod guide for x10
Reply With Quote
Scoochi2 is offlineReport Post
x10Hosting Member

Join Date: Jan 2008
Posts: 47
Credits: 691
Jose Magsino is on a distinguished road
Quote  
09-28-2008, 04:37 PM
Re: Python (beginner) - how do I get it running, starting from scratch?

page:
Code:
#!/usr/bin/python
print 1 + 1
but that didn't help.
Some of the advice given was
"Move file to cgi-bin directory and chmod it 755"

I don't know what 'chmod' means, so I have no idea what 'chmod it 755' means either. Can anyone help me and tell me what to do in layman's terms?

chmod means changing of file mode : when it is 755 .. that particularly, change the mode of your file to executable.

btw try changing your code to :
Code:
#!/usr/bin/python
print "Content-Type: text/html \r\n\r\n"
print 1 + 1
and changes also the mode of the file to executable as what Scoochi2 says in his reply to your post.

HTH.
Reply With Quote
Jose Magsino is offlineReport Post
x10Hosting Member

orange123's Avatar

Join Date: Sep 2008
Posts: 3
Credits: 243
orange123 is on a distinguished road
Quote  
09-29-2008, 12:04 PM
Re: Python (beginner) - how do I get it running, starting from scratch?

Thanks for the help. I use ftp instead of the file manager so I guess that's why I didn't see it, was pretty obvious really! The permissions were already on 755 though...
Does anyone else know how to get a basic python script working?
Thanks
Reply With Quote
orange123 is offlineReport Post
Reply

Tags
beginner, chmod, python

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get python running? Kugel Free Hosting 4 08-30-2008 07:01 PM
Running python cgi... itsech0 Free Hosting 1 12-09-2007 06:56 AM
Python / MySQLdb Korexio Free Hosting 9 11-29-2007 09:29 AM
How to use python? the_king_dollars Scripts & 3rd Party Apps 3 12-20-2006 12:22 PM


All times are GMT -5. The time now is 07:20 PM. Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0 RC7
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

Company Reports | Loans | Personal Loans | Debt Help | Credit Cards