When running on Windows the files run right out of the command prompts.
For Linux and Windows users that's not the case!
I get the following error:
Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/http/server.py", line 1158, in run_cgi os.execve(scriptfile, args, env) PermissionError: [Errno 13] Permission denied:
You'll need to the following to resolve these issues:
For Linux Users:
1) Ensure shebang is adjusted for Python 3 running on Linux and Mac OSX systems:
#!/usr/bin/env python3
2) Since the original executable files were written on windows they'll have hidden '\r' in the files that must be removed. Here are three possible ways:
a) In terminal command line type: tr -d ‘\r’ < input file name > output file name
(just rename the output file a new name --> erase old file --> then rechange output filename back to original)
b) In terminal command line type: cat inputfile | col -b > outputfile
(just rename the output file a new name --> erase old file --> then rechange output filename back to original)
c) Download dos2unix, then type in terminal command line: dos2unix input file name
3) Make file executable:
In terminal command line type:
a) chmod 755 filename
or
b) chmod +x filename
or
chmod a+x filename
For Mac OSX users it's almost the same:
- Repeat step 1) from Linux
- Repeat step 2) from Linux
For step 3 things change:
Based on the apache.org wiki page: https://wiki.apache.org/httpd/13PermissionDenied
It says that you have to make every executable from file location traversing all the away up to the /Users root directory.
You'll have to do the following.
3) In terminal command line:
a) type command: `cd /Users`
b) type command: `sudo chmod -R 755`
Now you can run your server .py file via:
sudo webserver.py
and the input file via normal:
python3 inputfile.py
Now you should be all good to go with no more permission errors! You can make necessary adjustments to shebang and command line if running python 2.
test.py
. That error may arise if the defined interpreter is not a valid executable. – Voyeur