#!/usr/bin/perl -w
# $Id: remote.sgml,v 1.2 2002/05/03 05:30:26 tom Exp $
use IO::Socket;
use strict;
# 3/22/2001 incorporate switches from "im"
# defaults ...
my $test = 0;
my $verbose = 0;
my $thing = "info";
my $host = "mount";
my $port = 5240;
#my $host = "kofa";
#my $port = 13; # daytime
while ( $_ = $ARGV[0] ) {
last unless /^-/;
shift;
# print "Arg: $_\n";
$test = 1 if /^-t/;
$verbose = 1 if /^-v/;
$host = "mmtcell" if /^-c/;
$thing = "stack" if /^-s/;
$thing = "time" if /^-t/;
$thing = "mem" if /^-x/;
$thing = "telpos" if /^-p/;
$thing = "telstat" if /^-m/;
$thing = "cellstat" if /^-n/;
}
# override host or port with environment variable.
if ( $ENV{MOUNT_HOST} ) {
$host = $ENV{MOUNT_HOST};
}
if ( $ENV{MOUNT_PORT} ) {
$port = $ENV{MOUNT_PORT};
}
# final override from command line
if ( $test ) {
$host = "mmvme2";
}
if ( defined $_ ) {
$thing = $_;
}
print "Asking $host (on port $port) for $thing\n" if $verbose;
my $sock = IO::Socket::INET->new (
PeerAddr => $host,
PeerPort => $port,
Proto => 'tcp'
);
die "No socket!! (Reason: $!)\n" unless $sock;
print $sock "$thing\n";
while ( defined($_ = <$sock>) ) {
last if /^.EOF/;
print;
}
close ($sock);
# THE END |