close
How to test if file exists on web?
http://unix.derkeiler.com/Newsgroups/comp.unix.shell/2008-08/msg00095.html
#!/bin/bash
url=$1
len=$(wget -S --spider "$url" 2>&1 | \
grep -E '^ Content-Length:|^213' | tail -n1 | \
sed 's/ Content-Length://;s/213//')
[[ -z "$len" ]] && echo "Invalid URL" && exit 1
echo "File length = $len"
secs=$(($(date "+86400-%-H*3600-%-M*60-%-S")))
{ sleep $secs; wget $url; }&
//檢查heartbeat.jsp
url=http://localhost/heartbeat.jsp
len=$(wget -S --spider --tries=10 "$url" 2>&1 | \
grep -E '^ Content-Length:' | \
sed 's/ Content-Length://')
[[ -z "$len" ]] && echo "Invalid URL" && exit 1
echo "File length = $len"
全站熱搜