Wednesday, December 11, 2013

CGIHTTPServer: The problem that Python script does not work.

When I use CGIHTTPServer, I caught problem that Python Script did not work.
So I checked a method to solve this problem, I show the method.

The problem is the following two points.

① Web browser downloads the Python script file without it run.

② The contents of the Python script file is displayed without it run.

Cause and Resolution


I shows the causes and solutions of ① and ②.

hoge.py: Represents the Python script that you want to run here.

Cause of ① 

It is caused by the fact that Python script does not have execute permission.
Please try running the following command.

$ ls -l

-rw-rw-r-- 1 ****** hoge.py

If the display as described above is, your script does not have execute permission.

Solutions to

Please give execute permission to your script with the following command.
$ chmod 755 hoge.py 

You check the execute permissions using the "ls -l" command.
Then you will see that "-" turns into "x".

-rwxr-xr-x 1 ****** hoge.py

Cause of

Since there is a possibility that the line feed code is at the cause, please check it.

$ file hoge.py 

Line feed code is incorrect in the case of the following display.

hoge.py: a python\015 script, ASCII text executable, with CRLF line terminators

The following message appears if the line feed code is correct.

hoge.py: a python script, ASCII text executable

Solutions to

Please correct line feed code.

$ nkf -file hoge.py > hoge_lf.py

Please check the line feed cord of hoge_lf.py.

hoge_lf.py: a python script, ASCII text executable

The following message appears if the line feed code is correct.

We have fixed the line feed code.


I hope that your problem will be solved in this solutions.

No comments:

Post a Comment