■ CGI スクリプト
CGI program
---------------------------------------------------------------------------------------
! /bin/sh

sub1() {
i=0
while [ $i -ne $cnt ]
do
if /usr/bin/grep START /tmp/timidity.status
        then
	echo "< br> < center> < font color=red size=5> $i < /font> < /center> < br>"
	/usr/local/bin/timidity /home/k-wada/timidity++/HOTARUJY-DODO.MID
	sleep 1
	i=`expr $i + 1`
	fi
done
}

sub2() {
i=0
while [ $i -ne $cnt ]
do
if /usr/bin/grep START /tmp/timidity.status
then
echo "< br> < center> < font color=red size=5> $i < /font> < /center> < br>"
	/usr/local/bin/timidity /home/k-wada/timidity++/hotaruno.mid
	sleep 1
	i=`expr $i + 1`
	fi
done
}

echo "Content-type: text/html"
echo
cat /usr/local/www/data/timidity/foo.html

case "$QUERY_STRING"
in
        *num=1)  cnt=1;; 
        *num=10)  cnt=10;;
        *num=50)  cnt=50;;
        *num=100) cnt=100;;
esac

case "$QUERY_STRING"
in
        mid=1*)echo "< br> 1 < br>"
	echo START > /tmp/timidity.status
	sub1;; 
        mid=2*)echo "< br> 2 < br>"
	echo START > /tmp/timidity.status
	sub2;;
        mid=3*) echo "- < br>"; sub3 ;;
        mid=4*) echo "- < br>"; sub4 ;;
        mid=STOP*) echo "STOP < br>";
	echo STOP > /tmp/timidity.status
	/bin/ps ax  > /tmp/timidity.tmp
	/usr/bin/grep /usr/local/bin/timidity /tmp/timidity.tmp > /tmp/timidity.ps 
	pid=`/usr/bin/awk '{print $1}' /tmp/timidity.ps`
	kill $pid
	echo "< font color=red> < b> KILL $pid < /b>< /font> < br>"
	j=`expr $j + 1`
esac