刚才想自制一个闹钟:
代码: 全选
weiyh@MyPC: at now + 10 minutes mplayer ~/Examples/ubuntu\ Sax.ogg
syntax error. Last token seen: m
Garbled time
代码: 全选
weiyh@MyPC: at now + 10 minutes mplayer ~/Examples/ubuntu\ Sax.ogg
syntax error. Last token seen: m
Garbled time
use the command format like this:iblicf 写了:我总是忘了煤气灶上烧的水,壶已经变形了
刚才想自制一个闹钟:
怎么也搞不定,。。。是不是at 有bug???????代码: 全选
weiyh@MyPC: at now + 10 minutes mplayer ~/Examples/ubuntu\ Sax.ogg syntax error. Last token seen: m Garbled time
代码: 全选
>> cat ~/bin/timetools
#!/bin/bash
#
x="false"
[ -z $1 ] && x="true"
[ -z $2 ] && x="true"
[ -z $3 ] && x="true"
function help
{
echo "用法:timetools [ 小时 分钟 秒 ] [ -h | --help ]"
}
case $1 in
-h)
help
exit 0;;
--help)
help
exit 0;;
[0-9][0-9])
hr=$1;;
[0-9])
hr="0$1" #一位数处理
;;
*)
if [ "$x" = "false" ] ; then
echo '用法错误!'
help
exit 1
fi;;
esac
case $2 in
[0-9][0-9])min=$2;;
[0-9])min="0$2";;
*)
if [ "$x" = "false" ] ; then
echo '用法错误!'
help
exit 1
fi;;
esac
case $3 in
[0-9][0-9])sec=$3;;
[0-9])sec="0$3";;
*)
if [ "$x" = "false" ] ; then
echo '用法错误!'
help
exit 1
fi;;
esac
if [ "$x" = "true" ] ; then
echo "输入小时: "
read hr
case $hr in
[0-9][0-9]);;
[0-9])
hr="0$hr" #一位数处理
;;
*)
if [ "$hr" != "" ] ; then
echo '用法错误!'
help
exit 1
fi;;
esac
echo "输入分钟: "
read min
case $min in
[0-9][0-9]);;
[0-9])min="0$min";;
*)
if [ "$min" != "" ] ; then
echo '用法错误!'
help
exit 1
fi;;
esac
echo "输入秒: "
read sec
case $sec in
[0-9][0-9]);;
[0-9])sec="0$sec";;
*)
if [ "$sec" != "" ] ; then
echo '用法错误!'
help
exit 1
fi;;
esac
fi
t="$hr:$min:$sec" # 't' is chort of 't'ime
while : ; do
ct=`date +%k:%M:%S` # 'ct' is chort of 'c'urrent 't'ime
if [ "$t" = "$ct" ] ; then
break
fi
sleep 1
done
kdialog --msgbox "计时结束"
#dialog --msgbox "计时结束" 10 10
exit 0
代码: 全选
] ls -ld //