TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG:10420] server info website



On Tue, 23 Nov 1999, Carl Wilhelm Soderstrom wrote:

>         what's the URL of that website where you can put a URL of a
> webserver into a CGI and it will return you some information about that
> machine (what webserver software, which OS)?
>         they've mentioned it on slashdot, but I never bookmarked it, and I
> can't find a good search string for slashdot to locate an article that
> mentions it.

Here's a little perl script that gets pretty much the same info.

-- 
Nate Carlson <carlson@real-time.com>    | Phone : (612)943-8700
http://www.real-time.com                | Fax   : (612)943-8500
#!/usr/bin/perl
# query.pl - simple webserver/proxy version utility
# made in perl.. etc
# I made a previous version but, lost it so I remade this
# which might be better.. still it works - just 
# ./query.pl <hostname of webserver>
# email: spline@linuxwarez.com 

use Socket;

my($remote,$port,$iaddr,$paddr,$proto,$line);
$remote = $ARGV[0];
$port = "80";

unless ($remote) {
  die "Usage:\nquery <hostname>\n\n";
}

$iaddr = inet_aton($remote) or die "Error: $!";
$paddr = sockaddr_in($port, $iaddr) or die "Error: $!";
$proto = getprotobyname('tcp') or die "Error: $!";

socket(SOCK, PF_INET, SOCK_STREAM, $proto) or die "Error: $!";
connect(SOCK, $paddr) or die "Error: $!";
$msg = "HEAD / HTTP/1.1 \n\n";

send(SOCK, $msg, 0) or die "Cannot send query: $!";

while ($hrm = <SOCK>) {
  if ($hrm =~ /Server:/) {
    $hrm =~ s/Server://;
    print "$remote: $hrm"; 
  }
}