2
我目前正在編寫一個Bash腳本來模擬網絡活動。這個想法是腳本運行了大約三個小時,然後終止。使用WGET模擬網絡活動
我已經沒有問題了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
你可以用空格定義IN,然後直接使用'for x in $ IN;像[我的版本](https://gist.github.com/rubo77/6f3abb42685237dfca16)和「few.vu.nl/~kgr700/ ..」一樣是空的 – rubo77