Jump to content

Read File In Cgi-Bin, Not Executed (Handle Like Text/plain?)


Recommended Posts

Posted

So, currently I'm using python's logging lib (import logging) to log "things" to a file, but the problem is the log file is created in the current directory (cgi-bin), so everything in it is consider as a cgi file, so if we access the log file it will respond with a 500 error, is there anyway to make a specific file extension being handle as text/plain, not being trying execute like cgi-script ?

My code:

import logging
logging.basicConfig(filename='protected.log')
logging.warning("will be logged")

I've tried create a htaccess that contain:

AddType text/plain .log

In both cgi-bin and "/" directory, but this doesn't work.

 

Also, if there's anyway to make the log file being write in parent ("/") directory also ok as the fix.

Posted

I would probably do it this way if I were you. Instead of running your script in public_html/cgi-bin/ run it in public_html/ Then create this public_html/.htaccess

AddHandler cgi-script .py
DirectoryIndex index.py
  • Like 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...