#1
  1. onCsdfeu
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Canada
    Posts
    100
    Rep Power
    12

    Various CGI problems


    Hey all. I've just bought my own piece of the web, a host with Python installed (there ain't that many!) and I started tinkering with cgis.

    After many problems (me == dumb enough to forget to chmod +x the scripts ) I was able to get the little bastards to run. Still, I'm having some problems.

    #1 The only error I EVER receive is the "500 Internal server error" or something like that. Is there nay way to get useful error messages ?

    #2 I'm trying to import a script - placed in the same folder as the one that's executed - and whether I name it script.py or script.cgi , it won't import and I get the 500 error. How could I solve that ?

    Thanks for the help again, d00ds.
    Time is the greatest of teachers ; sadly, it kills all of its students.
    - Hector Berlioz
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Ah i'm sure you'll have allot of fun when you get into it Solar..

    If you want to redirect errors to the browser you can just add this line to the top of your CGI..

    import sys; sys.stderr = sys.stdout

    alternativly you can use the cgitb module which will do the same thing but can also format the error message to make it easier to read.

    i dont know why it wont import though.. try one of the methods aobve and see what error you get. if you can solve it i sugest you kick your admins *** thats what i do.

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

  4. #3
  5. Wacky hack
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2001
    Location
    London, England
    Posts
    513
    Rep Power
    14
    Check sys.path? Your host may have set Python up so the path doesn't include the current working directory. That or you will need to find out your full absolute path and add that to sys.path, e.g.

    sys.path.append("/var/www/sites/myaccount/cgi-bin")

    Try that?
  6. #4
  7. Only the strong survives!!.
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Feb 2003
    Location
    A World of wonders.
    Posts
    5,583
    Rep Power
    407
    This is a generic error message and it can be caused by any number of problems.

    First and foremost, check your permissions, in this case probably not the script, but one or more of the other files that the script is trying to read or write to.

    Another possibility is you changed something else in the script causing a syntax error. Either check your programming skills, or start over with a fresh copy of the script.

    Also make sure that your not uploading your script in binary mode, o and one more thing.. it would be getter if you post your codes
  8. #5
  9. onCsdfeu
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Canada
    Posts
    100
    Rep Power
    12
    Originally posted by xlordt
    ...Either check your programming skills...
    Is there a module that allows that ?

    No, thanks a lot, guys, I'll be trying that as soon as I get a second or two or three.
    Time is the greatest of teachers ; sadly, it kills all of its students.
    - Hector Berlioz
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    89
    Rep Power
    13
    this used to happen to me when I found this free Python host a week ago, turns out it was a dumb mistake. I kept forgeting to write

    #!/usr/bin/python

    at the top of the file
  12. #7
  13. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    So 2k, u gonna make this the links , what host are you using?

    Anyway you should probably use '#!/usr/bin/env python' instead, this way you wont have to change your shebang for it to work on multiple systems.. and yes it works with the windows version of Apache too

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

  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    89
    Rep Power
    13
    www.1and1.com 3 years free hosting, 500 meg space with 5gb a month traffic. Python, Perl and PHP hosting with MySQL, etc..

    very good deal except you'll probably want to buy a domain name since you don't choose your domain name and the one they give you is pretty useless (ie sdfj454d.homeonline.us)

    Features:

    Website/Connectivity:
    Hosted on I/O optimized own 1&1 Linux version
    500 MB web space
    5,000 MB/month traffic ($.99 per GB for additional traffic)
    No limits on simultaneous hits/bandwidth
    Protected by firewall
    Continuous backups of your website
    99.9% Uptime guarantee


    Website features:
    Advanced live site statistics, log files, ready-to-run CGI-library, own CGI programming (Perl, Python), FrontPage 2002 extensions
    Advanced Password Protection
    5 FTP accounts
    PHP3 & PHP4
    MySQL
    Proxy SSL Secure Server
    Cron Jobs
    SSH Secure Shell Access
    Advanced Developer Tools
    CRM/E-commerce:
    WebElements
    Newsletter Tool
    One-on-one online dialogue
    Turn-key web database applications
    Chats
    Forums


    Domain names:
    Register or transfer .com/.net/.org/.info for just $5.99/year
    50 subdomains (e.g., shop.yourDomain.com)
    Point up to 100 external domain names to 1&1


    Applications:
    Free template loaded online WebsiteCreator
    Free full version of Fusion 7, search engine registration, ranking, optimization
    Total software worth $300
    1&1 Control Panel


    E-mail handling:
    50 POP3 e-mail accounts (50 MB each)
    Catch-all e-mail addresses
    Auto-responders, unlimited forwarding.
    1&1 Advanced WebMail
    Symantec virus scanner


    Support:
    1&1 Express support by e-mail
    Last edited by jimmy2k1; November 22nd, 2003 at 11:00 PM.
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Location
    Norway
    Posts
    41
    Rep Power
    12
    Originally posted by netytan

    alternativly you can use the cgitb module which will do the same thing but can also format the error message to make it easier to read.
    I didn't see it specified so here is how to use it. Add these 2 lines at the top of your script (after the other import statements is a nice place):
    Code:
    import cgitb
    cgitb.enable()
    If that doesn't print out any meaningful error messages either, run your script as a shell script (type "python script.py" in your shell).
    Good web hosting info - articles about web hosting
    hb's web dev blog

IMN logo majestic logo threadwatch logo seochat tools logo