Skip to content

Instantly share code, notes, and snippets.

@Liyuu8
Last active March 1, 2022 11:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Liyuu8/a55da2ba5f9ae977bbdf8f7f3bd0de76 to your computer and use it in GitHub Desktop.
Save Liyuu8/a55da2ba5f9ae977bbdf8f7f3bd0de76 to your computer and use it in GitHub Desktop.
# 実行権限を付与
vagrant@ubuntu-xenial:/vagrant_data$ chmod u+x cgi-bin/sample.py
# http.server を実行
vagrant@ubuntu-xenial:/vagrant_data$ python3.7 -m http.server --cgi
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
192.168.33.1 - - [17/Oct/2018 10:30:56] "GET /cgi-bin/sample.py HTTP/1.1" 200 -
# Error No.1
----------------------------------------
Exception happened during processing of request from ('192.168.33.1', 57505)
Traceback (most recent call last):
File "/opt/python3.7.0/lib/python3.7/http/server.py", line 1170, in run_cgi
os.execve(scriptfile, args, env)
OSError: [Errno 8] Exec format error: '/vagrant_data/cgi-bin/sample.py'
----------------------------------------
192.168.33.1 - - [17/Oct/2018 10:38:52] CGI script exit status 0x7f00
# shebang を追加することで解消
# Error No.2
/usr/bin/env: `python3.7\r': そのようなファイルやディレクトリはありません
192.168.33.1 - - [17/Oct/2018 10:30:56] CGI script exit status 0x7f00
# 改行コードを CRLF から LF に変更して解消
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment