Note that it took a lot of time to move the Python CGI file I was trying in the local environment of Windows to Mac OS X. Assuming a CGI file called upload.py under the cgi-bin folder.
Reference URL: http://d.hatena.ne.jp/yoshiya_na/20110521/1305978743
(1) Check / change the permissions of CGI files
cd cgi-bin
ls -lF
chmod 755 upload.py #Can be executed by all users, but cannot be written by anyone other than the owner
(2) Check the line feed code Unix, Mac OS X: LF Mac OS (up to version 9): CR Windows: CR-LF To match.
nkf -Lu --overwrite upload.py
Overwrite the original file and set the line feed code to LF.
Or, if you think about removing CR from a file created on Windows (reference: http://stackoverflow.com/questions/19425857/env-python-r-no-such-file-or-directory)
with open('upload.py', 'rb+') as f:
content = f.read()
f.seek(0)
f.write(content.replace(b'\r', b''))
f.truncate()
Recommended Posts