Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8452355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:28:42+00:00 2026-06-10T11:28:42+00:00

So basically, I’m a bit new to Python. I created a server and have

  • 0

So basically, I’m a bit new to Python. I created a server and have it up and running just fine, have the files and everything showing up.

But the problem is, every time I try to open a file, in Python, for reading/writing, my terminal throws an “access denied” error.

You know, it’s a basic server:

#!/usr/bin/env python
import BaseHTTPServer
import CGIHTTPServer
import cgitb

cgitb.enable();
server = BaseHTTPServer.HTTPServer;
handler = CGIHTTPServer.CGIHTTPRequestHandler;
address = ("",80);
handler.cgi_directories = ["/home"];

httpd = server(address,handler);
print("Working . . . ");
httpd.serve_forever();

Nothing too fancy. So I start the server up, and then when the user navigates to the page, “/home/file.py” that contains the code:

#!/usr/bin/env python
f = open("asdf.txt","w");

Nothing at all happens, and when I check the terminal that’s running the server, it says,

 localhost - - [27/Aug/2012 17:58:18] "GET /home/file.py HTTP/1.1" 200 -
 Traceback (most recent call last):
   File "/home/SERVER/home/file.py", line 4, in <module>
     f = open("asdf.txt","w");
 IOError: [Errno 13] Permission denied: 'asdf.txt'

I’ve been looking up this for awhile now, but I’ve yet to find a solution. It’s probably a very simple solution that would make professional Python users facepalm, but take into account that all self-taught programmers have to start somewhere. And for me, I’m a bit at the bottom right now, in Python terms at least.

I have tried a couple solutions I’ve found from the internet (and from the “Questions that may already have your answer”), like importing “os” and using that to specify the exact location to create file. I’ve tried using “sudo chmod g+w” on the SERVER folder and the folder that contains the Python scripts. But none of these interwebs solutions are helping me.

I’ll also remember to accept the answer.

I tried to make the question as precise as I could. So if there’s anything else you’d need to know, I can just update it.

Since it’s a “permission denied” error, I’m doubting it’s Python’s fault, and probably some permissions I didn’t setup somewhere. But I don’t know which or where they’d be.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:28:44+00:00Added an answer on June 10, 2026 at 11:28 am

    If you read the python docs on CGIHTTPServer:

    Note that CGI scripts will be run with UID of user nobody, for security reasons. Problems with the CGI script will be translated to error 403

    So this seems a little tricky unless you’re willing to leave all best practices behind and let
    anyone do stuff in your folder.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I have some simple code that does some things for files and I'm
Basically I have this server app I built in vc#, and for some reason
Basically, I have a UIImageView that will loop through 8 PNGs over 0.5 seconds.
Basically I have a large set of data in excel, and I was wondering
Basically, I have a list of delivery checkboxes one for deliver to this address
Basically, what is needed to perform multisampled deferred shading. To expand a bit: I'm
Basically I have an iframe loaded that is accessed from the parent whenever it
Basically, I have a JTextPane to hold some text which I wish to style.
Basically I have converted a tab delimited txt file into a list containing a
Basically I am writing a simple bit of code to increment every one second

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.