Jump to content


VlexoFree Notice

Interviews will be open every Friday starting at 12am PDT and lasting for 24 hours.

- - - - -

Python installed


  • This topic is locked This topic is locked
28 replies to this topic

#1 Jonathan J

Jonathan J

    Advanced Member

  • Pre-Members
  • 3,212 posts

Posted 25 May 2008 - 12:11 AM

Python was actually installed yesterday on the Reliability server, this is what python is:

Quote

A freeware open-source cross-platform interpreted scripting language from www.python.org.

You can go on hotscripts.com and find some neat python scripts, if you what to experiment with Python! :)


;) Can you moo like a cow? ;)

MOOOOO!

Posted Image

Current project: Armour.ws, ImageMoo.com Vlexo.com


Ad Bot


      #2 Davey G

      Davey G

        Advanced Member

      • Pre-Members
      • 907 posts
      • LocationBristol, UK

      Posted 25 May 2008 - 01:59 AM

      Yay! Awesome, thanks Jon :)

      Now, it's off to finish of the 'Open Source Website' .. :P

      Edit: http://goudou.me.uk
      Just shows the 'python' code.. No output/source :(

      Edited by Davey G, 25 May 2008 - 02:09 AM.



      thisisgoudou.com (portfolio)


      #3 vista07

      vista07

        Advanced Member

      • Pre-Members
      • 298 posts

      Posted 25 May 2008 - 02:03 AM

      Neat work! I was looking forward to work with Python!

      Thanks Jon

      #4 z.q.k

      z.q.k

        Newbie

      • Pre-Members
      • 2 posts

      Posted 25 May 2008 - 06:12 AM

      Great!

      #5 Nec

      Nec

        Advanced Member

      • Pre-Members
      • 505 posts

      Posted 25 May 2008 - 06:41 AM

      Hmm, will we be getting this on variable (apparently thats what Im on)?

      :: Aperture Global - Professional Web Services :: IRC, Community services, etc. ::
      :: Budget web design - Contact me ::


      #6 Jonathan J

      Jonathan J

        Advanced Member

      • Pre-Members
      • 3,212 posts

      Posted 25 May 2008 - 06:54 AM

      Yes. Just give me sometime and it'll be installed later today. As for the python support for reliability, David, could you try another script?


      ;) Can you moo like a cow? ;)

      MOOOOO!

      Posted Image

      Current project: Armour.ws, ImageMoo.com Vlexo.com


      #7 Nec

      Nec

        Advanced Member

      • Pre-Members
      • 505 posts

      Posted 25 May 2008 - 06:59 AM

      Jon: Alright, thanks :)

      Davey: Have you set the environment at the beginning? #!/usr/bin/python should work if that is where it is installed. That or #!/usr/bin/env python

      :: Aperture Global - Professional Web Services :: IRC, Community services, etc. ::
      :: Budget web design - Contact me ::


      #8 Davey G

      Davey G

        Advanced Member

      • Pre-Members
      • 907 posts
      • LocationBristol, UK

      Posted 25 May 2008 - 05:43 PM

      Jon and Necro.. Iv tried using #!/usr/bin/python and #!/usr/bin/env python with no success.

      Also heres what i see from the cPanel File Manager:
      Posted Image

      No python icon for the file, which is weird.. Possibly the sever isn't parsing Python scripts correctly?


      thisisgoudou.com (portfolio)


      #9 Nec

      Nec

        Advanced Member

      • Pre-Members
      • 505 posts

      Posted 25 May 2008 - 06:22 PM

      Well, if thats the case, you are right. The server is just treating it as a regular text file according to the mime type set. Apache isnt handling the python files correctly.

      :: Aperture Global - Professional Web Services :: IRC, Community services, etc. ::
      :: Budget web design - Contact me ::


      #10 lsproc

      lsproc

        Advanced Member

      • Members
      • 210 posts

      Posted 25 May 2008 - 10:50 PM

      Make sure the file has exec permissions.

      You might need it in the cgi-bin, but I might be wrong, I dont know the CGI setup here :)

      #11 maurobio

      maurobio

        Newbie

      • Pre-Members
      • 8 posts

      Posted 26 May 2008 - 10:21 AM

      Dear ALL,

      I also have problems trying to execute a test Python script:

      Here is the humble script I am trying to run:

      #!/usr/bin/python
      print "Content-type: text/html"
      print
      print "CGI 101"
      print "

      A First CGI Example

      " print "

      Hello, CGI World!

      "

      I put it on the "cgi-bin" folder of my webspace and give it all permissions (0777). On CPanel, I have also assigned an Apache handler to files with .py extension.

      I does not work! All I get back is the source listing of the script itself... :mad:

      Any hints, please?

      With warmest regards,
      Mauro Cavalcanti, from Rio de Janeiro, Brazil

      #12 Jan J

      Jan J

        Advanced Member

      • VlexoFree Support
      • 960 posts

      Posted 26 May 2008 - 02:02 PM

      maurobio said:

      ...
      Any hints, please?

      With warmest regards,
      Mauro Cavalcanti, from Rio de Janeiro, Brazil

      Just change the Extension to .cgi and you are going to be fine ! That's the point a lot of people bother with, just adding .cgi tells Apache to run this script in command line mode.

      wikipedia said:

      The Common Gateway Interface (CGI) is a standard protocol for interfacing external application software with an information server, commonly a web server.

      python is on your internal server, cause it is a powerful language and you do not want it to be accessed by public. So to execute a python script you need to pass your code through the gateway, which can be easily down by adding the extension .cgi and placing the file in the cgi-bin folder.

      If you do not want to execute your cgi files in this folder you can open up everyfolder to cgi ability by adding a .htaccess file that contains
      AddHandler cgi-script .cgi

      I think this will do for the moment. By the way I am really happy to see vlexo.net adding python support, but in my opinion to run bigger python projects like django commandline access is required. But that is just my very own opinion.
      Regards,
      Jan J

      #13 Garrett R

      Garrett R

        Advanced Member

      • Pre-Members
      • 1,480 posts

      Posted 26 May 2008 - 02:40 PM

      import antigravity;

      Oh, I'm flying! :D

      +5 internet points to anyone who gets this reference.

      #14 maurobio

      maurobio

        Newbie

      • Pre-Members
      • 8 posts

      Posted 26 May 2008 - 04:07 PM

      Dear Jan,

      Thank you very much for your explanation. I changed the extension of my humble CGI/Python test script (from "test.py" to "test.cgi")... but it still does not work! :mad: The server keeps returning me the obnoxious "500 Internal Server Error" message when I try to run the script using the URL: http://www.especies....gi-bin/test.cgi

      My best hint now it that the shebang line at the beginning of the script is not pointing correctly to the location of Python in the Vlexo server, anyway I cannot figure it out.

      I just hope that once this problem is solved, the solution may benefit many other current and future users -- I publicily offer to write a short tutorial on "Running Python scripts in Vlexo Hosting Service" and give it away to Vlexo for free distribution, in exchange for your support. :)

      Thanks for your patience, and time.

      With best regards,
      Mauro Cavalcanti, from Rio de Janeiro, Brazil

      #15 Nec

      Nec

        Advanced Member

      • Pre-Members
      • 505 posts

      Posted 26 May 2008 - 06:09 PM

      @ maurobio: Are permissions set correctly?

      @ Garrett: Its xkcd! :D

      :: Aperture Global - Professional Web Services :: IRC, Community services, etc. ::
      :: Budget web design - Contact me ::


      #16 maurobio

      maurobio

        Newbie

      • Pre-Members
      • 8 posts

      Posted 26 May 2008 - 07:30 PM

      I set permissions to 0777 and 0755 (the same of the other CGI scripts in cgi-bin directory) and the Python script does not work either... :eek:

      #17 Jan J

      Jan J

        Advanced Member

      • VlexoFree Support
      • 960 posts

      Posted 27 May 2008 - 03:18 AM

      I'm not sure what you did but my tips work for me :D

      I created a folder named "testing"
      created a file named ".htaccess" (important this is a hidden file)
      and a file called "py.cgi"
      filled the ".htaccess" file with
      AddHandler cgi-script .cgi
      and the py.cgi file with
      #!/usr/bin/python
      print "Content-type: text/html"
      print
      print "<title>CGI 101</title>"
      print "<h1>A First CGI Example</h1>"
      print "<p>Hello, CGI World!</p>"
      saved both.
      set the permission for "py.cgi" to 0755
      and was able to run your script:**offline**

      I am not sure what exactly went wrong but in general this should work in the cgi-bin folder as well, if not then try my method this is proven to work with vlexo.net !
      Regards,
      Jan J

      #18 maurobio

      maurobio

        Newbie

      • Pre-Members
      • 8 posts

      Posted 27 May 2008 - 05:25 AM

      Dear Jan,

      I got able to reproduce your steps - and, this time, it worked! :D:D:D

      Thank you very much indeed!

      A potentially interesting hint: it was not necessary for me to create a .htaccess file (as .cgi is already defined as a standard extension for server-side scripts).

      Well, as promised here, will now proceed to summarize all this and write-up a short "how-to" to donate the Vlexo support personnel and so help other users in the future.

      With warmest regards, :)

      Mauro Cavalcanti, from Rio de Janeiro, Brazil

      #19 lsproc

      lsproc

        Advanced Member

      • Members
      • 210 posts

      Posted 27 May 2008 - 05:40 AM

      If you would rather have your python scripts ending in .py, you could change the cgi-hander to .py instead of .cgi :)

      #20 Davey G

      Davey G

        Advanced Member

      • Pre-Members
      • 907 posts
      • LocationBristol, UK

      Posted 27 May 2008 - 07:16 AM

      Woot - now i gots it working :P Thanks Jan for the tips :)


      thisisgoudou.com (portfolio)





      0 user(s) are reading this topic

      0 members, 0 guests, 0 anonymous users