2014-10-28 48 views
-2
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的是挂在随机URL的,有没有什么办法把它试图给wget的URL,说最多然后在10秒,如果它不工作移到下一$行文本?wget的网址超时实现

谢谢!

+0

只是出于好奇,你甚至*尝试*研究之前问? – lxg 2014-10-28 23:10:37

回答

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.