bulk mark icecube and light them :
Code: Select all
#!/bin/bash
# *** Here begins program *** #
echo draw 2 "$0 is started.."
# *** Check for parameters *** #
[ "$*" ] && {
PARAM_1="$1"
# *** implementing 'help' option *** #
test "$PARAM_1" = "help" && {
echo draw 5 "Script to melt icecube."
echo draw 5 "Syntax:"
echo draw 5 "script $0 [number]"
echo draw 5 "For example: 'script $0 5'"
echo draw 5 "will issue 5 times mark icecube and apply filint and steel."
exit 0
}
# *** testing parameters for validity *** #
PARAM_1test="${PARAM_1//[[:digit:]]/}"
test "$PARAM_1test" && {
echo draw 3 "Only :digit: numbers as first option allowed."
exit 1 #exit if other input than letters
}
NUMBER=$PARAM_1
}
#|| {
#echo draw 3 "Script needs number of praying attempts as argument."
# exit 1
#}
#test "$1" || {
#echo draw 3 "Need <number> ie: script $0 50 ."
# exit 1
#}
f_exit(){
echo draw 3 "Exiting $0."
echo unwatch
#echo unwatch drawinfo
exit $1
}
# *** Actual script to pray multiple times *** #
test "$NUMBER" && { test $NUMBER -ge 1 || NUMBER=1; } #paranoid precaution
if test "$NUMBER"; then
for one in `seq 1 1 $NUMBER`
do
REPLY=
OLD_REPLY=
echo watch drawinfo
echo "issue 1 1 mark icecube"
while [ 1 ]; do
read -t 1 REPLY
echo "$REPLY" >>/tmp/cf_script.rpl
test "`echo "$REPLY" | grep 'Could not find an object that matches'`" && f_exit 1
#test "`echo "$REPLY" | grep '.*There are only.*'`" && f_exit 1
#test "`echo "$REPLY" | grep '.*There is only.*'`" && f_exit 1
test "$REPLY" || break
test "$REPLY" = "$OLD_REPLY" && break
OLD_REPLY="$REPLY"
sleep 0.1s
done
echo unwatch drawinfo
sleep 1s
NO_FAIL=
until [ "$NO_FAIL" ]
do
REPLY=
OLD_REPLY=
echo watch drawinfo
echo "issue 1 1 apply flint and steel"
while [ 1 ]; do
read -t 1 REPLY
echo "$REPLY" >>/tmp/cf_script.rpl
test "`echo "$REPLY" | grep 'fail'`" || NO_FAIL=1
#test "`echo "$REPLY" | grep '.*There are only.*'`" && f_exit 1
#test "`echo "$REPLY" | grep '.*There is only.*'`" && f_exit 1
test "$REPLY" || break
test "$REPLY" = "$OLD_REPLY" && break
OLD_REPLY="$REPLY"
sleep 0.1s
done
echo unwatch drawinfo
sleep 1s
done #NO_FAIL
done #NUMBER
else #PARAM_1
until [ "$NO_ICECUBE" ];
do
REPLY=
OLD_REPLY=
echo watch drawinfo
echo "issue 1 1 mark icecube"
while [ 1 ]; do
read -t 1 REPLY
echo "$REPLY" >>/tmp/cf_script.rpl
test "`echo "$REPLY" | grep 'Could not find an object that matches'`" && f_exit 1
#test "`echo "$REPLY" | grep '.*There are only.*'`" && f_exit 1
#test "`echo "$REPLY" | grep '.*There is only.*'`" && f_exit 1
test "$REPLY" || break
test "$REPLY" = "$OLD_REPLY" && break
OLD_REPLY="$REPLY"
sleep 0.1s
done
echo unwatch drawinfo
sleep 1s
NO_FAIL=
until [ "$NO_FAIL" ]
do
REPLY=
OLD_REPLY=
echo watch drawinfo
echo "issue 1 1 apply flint and steel"
while [ 1 ]; do
read -t 1 REPLY
echo "$REPLY" >>/tmp/cf_script.rpl
test "`echo "$REPLY" | grep 'fail'`" || NO_FAIL=1
#test "`echo "$REPLY" | grep '.*There are only.*'`" && f_exit 1
#test "`echo "$REPLY" | grep '.*There is only.*'`" && f_exit 1
test "$REPLY" || break
test "$REPLY" = "$OLD_REPLY" && break
OLD_REPLY="$REPLY"
sleep 0.1s
done
echo unwatch drawinfo
sleep 1s
done #NO_FAIL
done #true
fi #^!PARAM_1
# *** Here ends program *** #
echo draw 2 "$0 is finished."
It works as
#!/bin/ash
Almquist shell
provided by /bin/busybox
for me too .
Improvements welcome !