HTTP サーバにデータを取りに行く処理の shell スクリプト例 環境変数 HTTP_PROXY に サーバ:ポート が設定されている場合は それを利用する。メソッドとして、 GET または HEAD を指定する。 オプションとして no-cache を指定すると、proxy に対して キャッシュされた情報を使わないよう指示できる。 #!/bin/sh METHOD=$1 URL=$2 OPTION=$3 case "$HTTP_PROXY" in "") host=`expr $URL : 'http://\([^:/]*\)'` port=`expr $URL : 'http://[^:/]*:\([0-9]*\)'` file=`expr $URL : 'http://[^:/]*:*[0-9]*\(/*.*\)'` ;; *) host=`expr $HTTP_PROXY : '\(.*\):'` port=`expr $HTTP_PROXY : '.*:\(.*\)'` file=$URL ;; esac case "$port" in "") port=80 ;; esac exec tcpclient $host $port http.sh $METHOD $file $OPTION ここで使われる http.sh は次のようなもの。 #!/bin/sh echo "$1 $2 HTTP/1.0 " >&7 case "$3" in "no-cache") echo "Pragma: no-cache " >&7 echo "Cache-Control: no-cache " >&7 ;; esac echo " " >&7 7>&- cat <&6