-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfetch.sh
executable file
·50 lines (40 loc) · 885 Bytes
/
fetch.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
timestamp=$(date +%s)
host=''
subdomain=''
account=''
n=10
cache_buster=$(cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-z0-9' | fold -w 16 | head -n 1)
usage() { echo "Usage: fetch [-n <NumberOfTweets>] [-h <host>] [-t topic] account/topic/home" 1>&2; exit 1; }
while getopts ":h:n:t" o; do
case "${o}" in
h)
host=${OPTARG}
;;
n)
n=${OPTARG}
;;
t)
t=1
;;
*)
usage
;;
esac
done
shift "$((OPTIND - 1))"
account=${@: -1}
if [ -z "${account}" ]; then
account='home'
fi
if [ -n "${t}" ]; then
subdomain='t.'${subdomain}
fi
if [ -z "${host}" ]; then
usage
fi
for i in `seq 0 ${n}`;
do
#echo c${cache_buster}.b${timestamp}.p${i}.${account}.${subdomain}${host}
dig txt c${cache_buster}.b${timestamp}.p${i}.${account}.${subdomain}${host}| grep -A1 "ANSWER SECTION" | sed -n -e 's/.*TXT.//p'
done