Return to Snippet

Revision: 16452
at August 4, 2009 17:40 by sensimevanidus


Initial Code
#!/bin/bash
# HTTP Proxy Server's IP Address (or URL)
proxy_server=$1

# HTTP Proxy Server's Port Number
port=$2

# We're trying to reach this url via the given HTTP Proxy Server
# (http://www.google.com by default)
url="http://www.google.com"

# Timeout time (in seconds)
timeout=20

# We're fetching the return code and assigning it to the $result variable
result=`HEAD -d -p http://$proxy_server:$port -t $timeout $url`

# If the return code is 200, we've reached to $url successfully
if [ "$result" = "200 OK" ]; then
    echo "1 (proxy works)"
# Otherwise, we've got a problem (either the HTTP Proxy Server does not work
# or the request timed out)
else
    echo "0 (proxy does not work or request timed out)"
fi

Initial URL


Initial Description
This script tries to detect whether an HTTP Proxy works or not. It uses the HEAD command (high-level version of the lwp-request command) to connect to a given URL (http://www.google.com by default) via the given HTTP Proxy.
It takes 2 arguments; the first one is the IP Address or URL of the HTTP Proxy and the second one is its port number.
If you have a simpler or faster method, please let me know.

Initial Title
HTTP Proxy Checker

Initial Tags
http, validation

Initial Language
Bash