#!/afs/athena/contrib/perl/perl

($who,$where) = (($arg1 = $ARGV[0]) =~ /^(.*)@([^@]*)$/);

$where = $ARGV[0] unless $where;

($name,$aliases,$type,$len,$thataddr) = gethostbyname($where);

die "Couldn't resolve host $where\n" if ! $thataddr;

$that = pack('S n a4 x8', 2, 79, $thataddr);

# Make the socket filehandle.

if (socket(S, 2, 1, 6)) { 
    print "socket ok\n";
}
else {
    die $!;
}

if (connect(S,$that)) {
    print "connect ok\n";
}
else {
    die $!;
}

# Set socket to be command buffered.

select(S); $| = 1; select(STDOUT);

# send query

print S "$who\r\n";
print "<pre>\n";
print while(<S>);
print "</pre>\n";
