Server script.

Wrote this script a while back to use the server to get information for me. Here is a newer incarnation of that same script.

#!/bin/sh
echo “Content-type: text/html\n”
# read in our parameters
CMD=`echo “$QUERY_STRING” | sed -n ‘s/^.*cmd=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g”`
FOLDER1=`echo “$QUERY_STRING” | sed -n ‘s/^.*folder1=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g”| sed “s/%2F/\//g”`
FOLDER2=`echo “$QUERY_STRING” | sed -n ‘s/^.*folder2=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g”| sed “s/%2F/\//g”`
FOLDER3=`echo “$QUERY_STRING” | sed -n ‘s/^.*folder3=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g”| sed “s/%2F/\//g”`
FOLDER4=`echo “$QUERY_STRING” | sed -n ‘s/^.*folder4=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g”| sed “s/%2F/\//g”`
FOLDER5=`echo “$QUERY_STRING” | sed -n ‘s/^.*folder5=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g”| sed “s/%2F/\//g”`
FOLDER6=`echo “$QUERY_STRING” | sed -n ‘s/^.*folder6=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g”| sed “s/%2F/\//g”`
FOLDER7=`echo “$QUERY_STRING” | sed -n ‘s/^.*folder7=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g”| sed “s/%2F/\//g”`
FOLDER8=`echo “$QUERY_STRING” | sed -n ‘s/^.*folder8=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g”| sed “s/%2F/\//g”`
FOLDER9=`echo “$QUERY_STRING” | sed -n ‘s/^.*folder9=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g”| sed “s/%2F/\//g”`
FOLDERA=`echo “$QUERY_STRING” | sed -n ‘s/^.*folderA=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g”| sed “s/%2F/\//g”`
FOLDERB=`echo “$QUERY_STRING” | sed -n ‘s/^.*folderB=\([^&]*\).*$/\1/p’ | sed “s/%20/ /g”| sed “s/%2F/\//g”`
# our html header
echo “<html>”
echo “<head><title>Reports console</title></head>”
echo “<body>”
# test if any parameters were passed
if [ $CMD ]
then
case “$CMD” in
horo)
echo “Horoscope for $FOLDER5:<pre>”
/var/www/cgi-bin/ghp.sh “$FOLDER5″
echo “</pre>”
;;
whoro)
echo “Weekly horoscope for $FOLDERB:<pre>”
/var/www/cgi-bin/ghwp.sh “$FOLDERB”
echo “</pre>”
;;
weather)
echo “Weather for: $FOLDER4 :<pre>”
/var/www/cgi-bin/gwp.sh “$FOLDER4″
echo “</pre>”
;;
weather1)
echo “Weather for: $FOLDER9 :<pre>”
weather-util “$FOLDER9″
echo “</pre>”
;;
weather2)
echo “Weather for: $FOLDERA :<pre>”
/var/www/cgi-bin/gwp2cl.sh “$FOLDERA”
echo “</pre>”
;;
# ggtp)
# echo “Google translation for $FOLDER6:<pre>”
# /var/www/cgi-bin/ggtp.sh “$FOLDER6″ “$FOLDER1″ “$FOLDER2″
# echo “</pre>”
# ;;
#
glpp)
echo “Lottery balls picks using $FOLDER7 with choices) out of $FOLDER8 ball(s).<pre>”
/var/www/cgi-bin/glpp.sh “$FOLDER7″ “$FOLDER8″
echo “</pre>”
;;
gtlp)
echo “Terror threat level :<pre>”
/var/www/cgi-bin/gtlp.sh
echo “</pre>”
;;
*)
echo “Unknown command $CMD<br>”
;;
esac
fi
# print out the form
# page header
echo “<p>”
echo “<hr>”
echo “<center><h2>”
echo “Reports console for: “
# echo “Test server”
uname -n
echo “<p>”
echo “<a href=”http://oesrvr1″&gt; Click on me to return to the homepage!</a>”
echo “</h2></center>”
echo “<hr>”
echo “<p>”
echo “<form method=get>”
echo “Choose which report you want to run: <br>”
echo “<input type=radio name=cmd value=weather > Weather (enter zip code) <input type=text name=folder4 value=22546> <br>”
echo “<input type=radio name=cmd value=weather1 > Weather (enter airport code) <input type=text name=folder9 value=FWT> <br>”
echo “<input type=radio name=cmd value=weather2 > Weather (enter zip code) <input type=text name=folderA value=22546> <br>”
echo “<input type=radio name=cmd value=horo> Horoscope (enter sign) <input type=text name=folder5 value=virgo> <br>”
echo “<input type=radio name=cmd value=whoro> Weekly horoscope (enter sign) <input type=text name=folderB value=virgo> <br>”
#
# echo “<input type=radio name=cmd value=ggtp> Google translate (enter convert from) <input type=text name=folder1 value=es> (enter convert to) <input type=text name=folder2 value=en><br> (enter word to convert) <input type=text name=folder6 value=toro><br>”
#
echo “<input type=radio name=cmd value=glpp> Lottery picks (enter # of picks) <input type=text name=folder7 value=6> (enter # of balls) <input type=text name=folder8 value=50><br>”
echo “<input type=radio name=cmd value=gtlp> Terror threat level”
echo ” <br><br>”
echo “<input type=submit>”
echo “</form>”
echo “</body>”
echo “</html>”

Comments

Popular posts from this blog

Guiless?

MSOffice vs Libreoffice

Raspberry pi zero.