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 8086545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:29:20+00:00 2026-06-05T18:29:20+00:00

I am running the following command from my home directory: python -m CGIHTTPServer This

  • 0

I am running the following command from my home directory:

python -m CGIHTTPServer

This runs the server, but when I try to access a script in the cgi-bin directory I get:

Traceback (most recent call last):
  File "/usr/lib/python2.7/CGIHTTPServer.py", line 251, in run_cgi
    os.execve(scriptfile, args, env)
OSError: [Errno 13] Permission denied

Running as root does not make a difference. The files seem to have all the right permissions:

student@bandersnatch:~$ ls -lhR
.:
total 12K
drwxr-xr-x 2 student student 4.0K Jun 13 18:38 cgi-bin
drwxr--r-- 2 student student 4.0K Jun 10  2004 kalpy
-rwxrwxrwx 1 student student 2.0K Jun 13 12:37 test.html

./cgi-bin:
total 8.0K
-rwxr-xr-x 1 student student 31 Jun 13 18:38 test.py

Edit: The content of test.py is:

#!/usr/bin/python
print "test"

The shebang is valid:

~$ which python
/usr/bin/python
  • 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-05T18:29:21+00:00Added an answer on June 5, 2026 at 6:29 pm

    Are you, by any chance, running the process as root?

    If you use the source, you will see in CGIHTTPServer.py, just before calling execve:

    try:
        os.setuid(nobody)
    except os.error:
        pass
    

    That is, it will run the CGI script as nobody, if it is able to change the UID, that is if it is root. If it is not root, this call will most likely fail, and pass on.

    So my guess is that you are running the server as root, so the script is run as nobody, but this user doesn’t have access to the script. Which is expected, as you say that it is in your home dir.

    Two solutions that I can think of:

    • The recommended: do not run the server as root!
    • The workaround: copy the script to a directory where nobody can read it (/tmp for example).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running a script fine from the command line, but it fails when put
From this guide , I have successfully run the sample exercise. But on running
I am running the following command in cpanel /ramdisk/bin/php5 -q /home#/username/etc/php.ini /home#/username/public_html/sitename/subfolder/twitter.php It is
I'm running the following line from the apache logs directory to move older (previously
How do you return 0 instead of null when running the following command: SELECT
I am getting the following error after running git svn rebase: 'update-index --refresh: command
When running the rake db:structure:dump command, I encountered the following error: Larson-2:app larson$ rake
I am running following query. SELECT T1.C1, T2.C2..., IF( T1.C1<>T2.C1,Changed,1) AS NewColumn From T1
I am running following query.. Select T1.* from T1 LEFT JOIN T2 ON T1.C1
When running the following python code: >>> f = open(rmyfile.txt, a+) >>> f.seek(-1,2) >>>

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.