2014-10-28 73 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.