Created
November 14, 2016 05:58
-
-
Save okura3/e7fb87a9448ecd15be9de5f26e5d0b39 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# perl CGI デバッグ用ラッパースクリプト | |
# 使用方法 : ./cgi_wrapper.sh CGIプログラム | |
# REQUEST_METHOD, POST(POSTデータ), QUERY_STRING は | |
# 本スクリプト外で設定することができる。 | |
export LANG=C | |
export TZ=JST-9 | |
export REQUEST_METHOD=POST | |
if [ "X$REQUEST_METHOD" == "XPOST" ]; then | |
export POST=${POST:-} | |
export CONTENT_TYPE=application/x-www-form-urlencoded | |
else | |
export QUERY_STRING=${QUERY_STRING:-} | |
fi | |
export REQUEST_SCHEMA=${REQUEST_SCHEMA:-https} | |
export HTTP_COOKIE=クッキー値 | |
export HTTP_HOST=ホスト名 | |
export HTTP_USER_AGENT=ユーザエージェント | |
export HTTP_REFERER=リファラー | |
export REMOTE_ADDR=クライアントIP | |
export REMOTE_USER=認証ユーザ名 | |
CGI_BASE="cgi-bin のディレクトリ名" | |
export SERVER_NAME=サーバ名 | |
PROG=$1 | |
export SCRIPT_NAME=${PROG##*/} | |
DIR=${PROG%/*} | |
if [ "X$PROG" == "X$DIR" ]; then | |
DIR=$(pwd) | |
else | |
DIR=$(cd $DIR; pwd) | |
fi | |
if [ "X$REQUEST_SCHEMA" == "Xhttps" ]; then | |
export SERVER_PORT="443" | |
else | |
export SERVER_PORT="80" | |
fi | |
export SCRIPT_FILENAME="$DIR/$SCRIPT_NAME" | |
export REQUEST_URI=${SCRIPT_FILENAME#$CGI_BASE} | |
export SCRIPT_URI="${REQUEST_SCHEMA}://${SERVER_NAME}${REQUEST_URI}" | |
export SCRIPT_URL="$REQUEST_URI" | |
cd $DIR | |
if [ "X$REQUEST_METHOD" == "XPOST" ]; then | |
export CONTENT_LENGTH=$(echo -n $POST | wc -c) | |
echo $POST | perl -d $SCRIPT_NAME | |
else | |
perl -d $SCRIPT_NAME | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment