-
Notifications
You must be signed in to change notification settings - Fork 3
/
proxy-lasttest.sh
executable file
·66 lines (62 loc) · 2.06 KB
/
proxy-lasttest.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
#########################################################################
#Name: proxy-lasttest.sh
#Subscription: This script makes makes a proxy test
#by N. Vongeheur
#
#License:
#This program is free software: you can redistribute it and/or modify it
#under the terms of the GNU General Public License as published by the
#Free Software Foundation, either version 3 of the License, or (at your option)
#any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
#or FITNESS FOR A PARTICULAR PURPOSE.
#########################################################################
#Set the language
export LANG="en_US.UTF-8"
#Load the Pathes
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
function usage() {
echo " Usage:"
echo " $(basename $0) -c COUNT -f /Path/to/url_file -h PROXY_HOST -p PROXY_PORT"
echo ""
echo " -c COUNT How often should the URLs be called"
echo " -f /Path/to/url_file File with target URLs (One per line)"
echo " -h PROXY_HOST Which Proxy to use"
echo " -p PROXY_PORT Proxy Port"
echo " -s Silent-Mode"
exit 1
}
while getopts "c:f:p:h:s" opt
do
case ${opt} in
c) COUNT=${OPTARG}
;;
f) URLS=${OPTARG}
;;
h) PROXY_HOST=${OPTARG}
;;
p) PROXY_PORT=${OPTARG}
;;
s) SILENT="-s"
;;
*) usage
;;
esac
done
[ -z "$1" ] && usage
#[ -z ${COUNT} -o -z ${URLS} -o -z ${PROXY_HOST} -o -z ${PROXY_PORT} ] && usage
[ -n "${PROXY_HOST}" ] && PROXY_STRING="-x http://${PROXY_HOST}:${PROXY_PORT}"
for ((c=0; c<=${COUNT}; c++))
do
cat ${URLS} |
while read url
do
CHECK_OUT=$(curl -k ${SILENT} ${PROXY_STRING} ${url} | grep "The domain name does not exist")
RC=$?
[ -z "${CHECK_OUT}" -a "${RC}" = 1 -a -z "${SILENT}" ] && echo "${url} wurde erfolgreich aufgerufen"
[ -n "${CHECK_OUT}" -o "${RC}" != 1 ] && echo "WARNING: ${url} wurde nicht erfolgreich aufgerufen"
[ -z "${SILENT}" ] && echo ""
done
done