HTTP Proxy Checker in bash

Usefull script  to check if a proxy is alive.

 bash | 
 
 copy code |
?

01
#!/bin/bash
02
# HTTP Proxy Server's IP Address (or URL)
03
proxy_server=$1
04
05
06
# HTTP Proxy Server's Port Number
07
08
port=$2
09
10
# We're trying to reach this url via the given HTTP Proxy Server
11
12
# (http://www.google.com by default)
13
url="http://www.google.com"
14
15
16
# Timeout time (in seconds)
17
18
timeout=20
19
20
# We're fetching the return code and assigning it to the $result variable
21
result=`HEAD -d -p http://$proxy_server:$port -t $timeout $url`
22
23
# If the return code is 200, we've reached to $url successfully
24
if [ "$result" = "200 OK" ]; then
25
    echo "1 (proxy works)"
26