$sleep = 60 unless $sleep;
$idle = 999E10 if $all;
if ( $ARGV[0] =~ /^-/ ) {
select (stderr);
printf "usage: %s [vars] [-b | -m] [-a] [-n] [-l] [-w] [-s] [target ...]\n",
$me;
printf "\t-b to broadcast to the ruserd\n";
printf "\t-m to multicast to the ruserd\n";
printf "\t-a for ALL, even very idle people\n";
printf "\t-n for people active NOW short idles\n";
printf "\t-l for LONG listing\n";
printf "\t-w to dynamically compute WINDOW size\n";
printf "\t-s to sleep and repeat until all targets found\n";
printf "\tvars \$idle ($idle) and \$sleep ($sleep) can be set with var=value\n";
printf "\t as can \$hosts, \$dot ($dot), and \$colon ($colon)\n";
exit 1;
}
if ( $window ) {
open(win,"(stty all > /dev/tty ) 2>&1 |") || die "can't run stty";
while (<win>) {
chop; split;
$cols = int($_[7]/ 25);
last;
}
close win;
}
$cols = 3 unless $cols;
if ($multicast && !$hosts) {
$machines = '/usr/adm/MACHINES';
open machines || die "$me: can't open $machines: $!\n";
open(saveout, ">&stdout"); # much cheaper than invoking sh
close(stdout);
while (<machines>) {
next if /norpc/;
chop;
s/\s.*//;
if (do ping($_)) { # no sh here!
#print stderr $_, " ok\n";
push(@hosts,$_);
} else {
#printf stderr "%s is down!\n", $_;
}
}
open(stdout, ">&saveout");
close machines;
close saveout;
$debug && print "hosts are: ", join(' ',@hosts),"\n";
}