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.
- # HTTP Proxy Server's IP Address (or URL)
- # HTTP Proxy Server's Port Number
- # We're trying to reach this url via the given HTTP Proxy Server
- # (http://www.google.com by default)
- # Timeout time (in seconds)
- # 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)
- echo "0 (proxy does not work or request timed out)"
CommentsSubscribe to comments
You need to login to post a comment.