$ls -l /home/httpd/cgi-bin/poff_flagset.cgi
-rwxr-xr-x 1 root root 2175 Jul 9 14:55 /home/httpd/cgi-bin/poff_flagset.cgi
$cat /home/httpd/cgi-bin/poff_flagset.cgi
#! /bin/sh
before=`cat /home/httpd/html/poff/poff_flag`
#htmlからのパラメータを受信
read param
# '&'と'='をスペースに置き換え、1番目のパラメータ(name)を取りだしている。
name=`echo "$param" | sed -n '/CONTROL/s/=/ /pg' |
sed -n '/CONTROL/s/&/ /pg'| awk '{print $1}'`
# '&'と'='をスペースに置き換え、2番目のパラメータ(value)を取りだしている。
value=`echo "$param" | sed -n '/CONTROL/s/=/ /pg' |
sed -n '/CONTROL/s/&/ /pg'| awk '{print $2}'`
# 残り時間の計算
time=`date | awk '{print $4}' | sed -n '/:/s/:/ /pg' | awk '{print $2}'`
if [ $time -lt 10 ]; then
r_time=`expr 10 - $time`
elif [ $time -lt 20 ]; then
r_time=`expr 20 - $time`
elif [ $time -lt 30 ]; then
r_time=`expr 30 - $time`
elif [ $time -lt 40 ]; then
r_time=`expr 40 - $time`
elif [ $time -lt 50 ]; then
r_time=`expr 50 - $time`
else
r_time=`expr 60 - $time`
fi
if [ $before = "OFF" ] ; then
bword="$r_time分後にシャットダウン"
elif [ $before = "INIT" ] ; then
bword="`expr $r_time + 10`分後にシャットダウン"
elif [ $before = "REBOOT" ] ; then
bword="$r_time分後に再起動"
else
bword="通常運転"
fi
# WebPage作成スクリプト
echo "Content-type:text/html"
echo ""
echo "<head><title>すずきさんちのサーバ制御</title></head>"
echo "<body>"
echo "サーバ情報<br><br>"
if [ "CONTROL" = "$name" ] ; then
if [ $before = $value ] ; then
echo "状況は変わってござらんよ。"
else
echo "$value" > /home/httpd/html/poff/poff_flag
echo "状況が変わったでござる。"
echo "今までは<font color=blue>$bword</font>するつもりであったが、"
before=`cat /home/httpd/html/poff/poff_flag`
fi
fi
# echo "<br>今は`cat /home/httpd/html/poff/poff_flag`だよ<br><br>"
if [ "OFF" = $before ] ; then
echo "今から<font color=red>$r_time分後にシャットダウン</font>するダニよ<br>"
elif [ "INIT" = $before ] ; then
echo "今から<font color=red>`expr $r_time + 10`分後にシャットダウン</font>するダニよ<\
br>"
elif [ "REBOOT" = $before ] ; then
echo "今から<font color=red>$r_time分後に再起動</font>するダニよ<br>"
else
echo "<font color=blue>通常運転中</font>でござるよ<br>"
fi
echo "<br>`date | awk '{print $2,$3,$4}'`</br>"
echo "</body>"
|