Created
April 9, 2014 17:24
-
-
Save intel352/10294333 to your computer and use it in GitHub Desktop.
Webtail - continously tail a long-running remote webpage/file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
POLLING_INTERVAL=2 | |
CONTENT_LENGTH=0 | |
while true | |
do | |
FETCH_CONTENT_LENGTH=`curl -s -r 0-0 -I $1 | egrep -i "Content-Range" | cut -d/ -f2 | awk -F"\r" '{print $1}'` | |
TMP_CONTENT_LENGTH=$FETCH_CONTENT_LENGTH | |
if [[ $TMP_CONTENT_LENGTH > $CONTENT_LENGTH ]] | |
then | |
if [[ $CONTENT_LENGTH == 0 ]] | |
then | |
curl -N -s -r -500 $1 | |
else | |
REMAINING=$CONTENT_LENGTH-$TMP_CONTENT_LENGTH | |
curl -N -s -r $REMAINING $1 | |
fi | |
CONTENT_LENGTH=$TMP_CONTENT_LENGTH | |
fi | |
sleep $POLLING_INTERVAL | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment