我目前正在编写一个 Bash 脚本来模拟 Web 事件。这个想法是脚本运行大约三个小时,然后终止。
我对 wget 没问题,oneliner 在 cmd 行上工作得很好 代码在这里:
#!/bin/bash
a=$(date +%s)
echo current time is $a
b=$(($a + 10800)) # finish time is start time plus 10800 number of seco\
# nds in three hours
echo finish time is $b
for line in "url_list.txt"; do
echo current url is $line
date=$(date +%s)
echo current time is $c
wget -e \
-r -p -l 1 -T 60 \
--random-wait --user-agent="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.3) Gecko/2008092416 Firefox/3.0.3" \
--convert-links\
echo "downloading..."
echo "Calculating if three hours has passed..."
if (("$date" > "$b"))
then
echo "3 hours has passed£
break
else
echo sleep for 5 seconds
sleep 5;
done;
我收到错误:
url_request.sh: line 26: syntax error near unexpected token `done'
url_request.sh: line 26: ` done'
发生了什么事,我看不到?
最佳答案
在 bash 中,您以 fi
结束 if
结构,而不是 done
关于bash - 使用 WGET 模拟 Web 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21042732/