Prints out the IP address of any machine that responds with a well formed message in a timely manner to a HTTP GET request. Useful for finding Win32 clients that haven't disabled IIS.
use LWP::UserAgent; use strict; my $agent = new LWP::UserAgent; $agent->agent("RDFmilla/0.1"); my $base = "192.168.0."; # change this according to local preference for my $ip (1 .. 255) { print "Trying $base$ip "; my $req = new HTTP::Request GET => "http://$base$ip/"; my $result = $agent->request($req); if ($result->is_success) { print "valid HTTP reply from $base$ip\n"; } else { print "no reply\n"; } }

Replies are listed 'Best First'.
Re: Find all webservers on local domain
by split (Initiate) on Mar 27, 2002 at 17:17 UTC
    It works well, where did you get that "RDFmilla/0.1"? how about Apache Web server? BTW, I set timeout to 1 sec, the default of 3 min is too much for me. $agent->timeout(1);
      where did you get that "RDFmilla/0.1"?
      1. In the best traditions of Perl, I made it up
      how about Apache Web server?
      1. Anything that supplies a valid response to a GET request on Port 80 will be considered a success
      I set timeout to 1 sec
      1. So you've never come across an (potentially poorly configured) index page that talks to a database? Or an Application Server? Defaults are there for a reason.

      Thanks for your comments, I know it could be much better, but it works well enough for what I want and I was happy to share it with the community. That is not an admission of support though :)

      rdfield

        thanks for your reply! I didn't use LWP::UserAgent before and thought "RDFmilla/0.1" was something specific to IIS from your description. You are right on default timeout, I only want to test your script and don't have enough patient :), thought it stalled after a long silence...