我正在尝试创建一个脚本,以便在信息亭使用时间。
以下的secipt给了我错误:
'第30行:语法错误:意外的文件结尾'
我读过关于不结束循环可能会导致此错误,但我无法弄清楚我哪里出错了。
#!/bin/bash
#time notifications
while true
xmessage "Click OK to begin your session." -buttons OK -center
start=$SECONDS
answer=0
while $answer = 0
while [`echo "($SECONDS - $start) % 300" | bc` != 0]
end
answer=$[xmessage "You started (($SECONDS - $start)/60) minutes ago." -buttons continue:0,done:1 -center]
end
end
答案 0 :(得分:1)
你有一些重要的逻辑错误需要处理。我提供了一个启动会话的工作示例,并设置了10秒计时器。在每10秒结束时,系统会显示一个消息框,询问Continue
,Done
。该对话框跟踪跟踪您使用会话的total
秒。定时器每10秒重置一次:
#!/bin/bash
#time notifications
while true; do
xmessage "Click OK to begin your session." -buttons OK -center
SECONDS=$(date +%s)
answer=0
start=$SECONDS
while [ "$answer" -eq 0 ]; do
timer=$SECONDS
## temporary 10 second timer used for illustration
while [ $((SECONDS - timer)) -lt 10 ]; do
SECONDS=$(date +%s)
sleep 1
done
xmessage "You started $((SECONDS - start)) seconds ago." \
-buttons continue:0,done:1 -center
answer=$?
done
[ $answer -gt 0 ] && break
done