while read -r line; do
wget -O /dev/null -S "$line" 2>&1 | grep -q -m 1 "Expires: Sun, 19 Nov 1978 05:00:00 GMT"
if [ ${PIPESTATUS[1]} -eq 0 ]; then # check greps return code
echo "Yes"
echo "$line" >> yes_urls.txt
else
echo "No"
fi
done < text.txt
我的wget挂在随机网址上,有没有办法让它尝试忘记最长10秒的网址然后如果它不起作用又转移到文本中的下一个$行?
谢谢!
答案 0 :(得分:0)
或许像--timeout
这个论点?
--timeout=seconds
Set the network timeout to seconds seconds. This is equivalent to
specifying --dns-timeout, --connect-timeout, and --read-timeout,
all at the same time.
When interacting with the network, Wget can check for timeout and
abort the operation if it takes too long. This prevents anomalies
like hanging reads and infinite connects. The only timeout enabled
by default is a 900-second read timeout. Setting a timeout to 0
disables it altogether. Unless you know what you are doing, it is
best not to change the default timeout settings.
All timeout-related options accept decimal values, as well as sub-
second values. For example, 0.1 seconds is a legal (though unwise)
choice of timeout. Subsecond timeouts are useful for checking
server response times or for testing network latency.