www.webdeveloper.com
Results 1 to 2 of 2

Thread: problems with an python cgi script in apache

  1. #1
    Join Date
    Mar 2010
    Location
    Finland
    Posts
    84

    problems with an python cgi script in apache

    Hi, I have a python cgi script (called image.cgi) which works fine when I run it from the terminal as a py script, but when I try and run it from my apache web directory, I get the following error in the apache log.
    [Sun Apr 18 11:30:39 2010] [error] [client 127.0.0.1] Traceback (most recent call last):
    [Sun Apr 18 11:30:39 2010] [error] [client 127.0.0.1] File "/var/www/public_html/grooveshark/image.cgi", line 19, in <module>
    [Sun Apr 18 11:30:39 2010] [error] [client 127.0.0.1]
    [Sun Apr 18 11:30:39 2010] [error] [client 127.0.0.1] text_file = open("trackDB.txt", "w") # create the DB
    [Sun Apr 18 11:30:39 2010] [error] [client 127.0.0.1]
    [Sun Apr 18 11:30:39 2010] [error] [client 127.0.0.1] :
    [Sun Apr 18 11:30:39 2010] [error] [client 127.0.0.1] [Errno 13] Permission denied: 'trackDB.txt'
    [Sun Apr 18 11:30:39 2010] [error] [client 127.0.0.1]
    The error seems to say that the access to trackDB.txt is denied, but I have the file access at 755 (trackDB.txt will just have some text written to it).
    A regular python cgi script seems to work for example, a simplified version of my code with error catching...
    Code:
    #!/usr/bin/env python
    
    import Image, ImageDraw, ImageFont, random, feedparser
    import cgi
    
    print "Content-type: text/html"
    print
    	
    try:	
    	
        print '''
    	<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    	<html>
    	<head>
    	<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
    	<script language = "JavaScript" src="grooveshark.js"></script>
    	<title>GrooveShark sig</title>
    	</head>
    	<body>
    	'''
    	
        print '<a href="http://google.com"><img src="test.png"></a><p>Hello</p>'
        print "world"
        
        print '''
    	</body>
    	</html>
    	'''
    
    except:
        import cgi
        cgi.print_exception()
    Works just fine.

    Does anyone have any ideas what is happening. BTW, the output in the browser is just a blank page.

    Thanks.

  2. #2
    Join Date
    Jun 2009
    Location
    Miami
    Posts
    118
    Check the owner (uid) of the file to make sure that it is the effective uid of what is running the script since -rwx- permission is given in that case. Write permission is not given to the group or others! Resolve that conflict.

    Errno 13 probably refers to a standard Unix error code (EPERM, I am guessing).

    Perhaps a google search helps too? I tried this:

    http://www.daniweb.com/forums/thread128505.html

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles