• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 281
  • Last Modified:

testing proxy

hello.

I need a small script to test if a proxy is working, or not.
0
tilih
Asked:
tilih
1 Solution
 
shlomoyCommented:
#!/usr/bin/perl -w
use strict;
use LWP::UserAgent;

my $ua = LWP::UserAgent->new;

if (defined $ARGV[0]) {

    $ua = LWP::UserAgent->new;
    $ua->proxy(["http", "ftp"], "http://proxy.myproxy.net:3128");
    my $request = HTTP::Request->new("GET", "http://cnn.com/");
    my $response = $ua->request($request);
    print $response->status_line,"\n";

} else {


    $ua = LWP::UserAgent->new;
    my $request = HTTP::Request->new("GET", "http://cnn.com/");
    my $response = $ua->request($request);
    print $response->status_line,"\n";

}                                                    



of course you need to change http://proxy.myproxy.net:3128 to the url of the proxy you want to test.


if this script gets a commandline argument (no matter which) - it will try to use the proxy, otherwise it will try going direct.    
0
 
tilihAuthor Commented:
does the job.
thank you
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now