#!/usr/bin/perl # /usr/local/bin/perl5.003 @blue_lines = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); @chico_lines = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); @mandy_lines = (1, 2, 3, 4, 5, 6, 7, 8, 13, 14, 15, 16); @tally_lines = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); @kat_lines = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12); @mojo_lines = (1, 2, 3, 4, 5, 6, 7, 8, 9); # See who's logged in $blue_busy = &finger_terminal_server("blue",@blue_lines); $chico_busy = &finger_terminal_server("chico",@chico_lines); $mandy_busy = &finger_terminal_server("mandy",@mandy_lines); $tally_busy = &finger_terminal_server("tally",@tally_lines); $kat_busy = &finger_terminal_server("kat",@kat_lines); $mojo_busy = &finger_terminal_server("mojo",@mojo_lines); # Is $n a member of @list? sub In { local($n, @list) = @_; local($i, $match); $i = 0; $match = 0; while (!$match && $i <= $#list) { if ($n == $list[$i]) { $match = 1; } $i++; } return $match; } # See who's logged on to a given terminal server. sub finger_terminal_server { local($termserv, @termserv_lines) = @_; local($dummy, $lineno, $line, $username, $rest, @busy, $all_busy); $all_busy = 1; open(FINGER,"finger @$termserv|") || die "couldn't run finger process: $!"; # Skip past the banner. for (;;) { $_ = ; last if (/\s*Line/); } while () { ($dummy, $lineno, $line, $username, $rest) = unpack("A2 A3 A8 A10 A*", $_); print "$username\n"; } return $all_busy }