home *** CD-ROM | disk | FTP | other *** search
- eval 'exec /bin/perl -wS $0 ${1+"$@"}'
- if 0;
-
- #
- # A Perl version of the rather screwy Xenix "wall" command.
- # Written by Chip Salzenberg, 3 May 1990.
- #
-
- $| = 1;
-
- $_ = `who am i 2>/dev/null`;
- chop;
- ($me) = split;
- $me = "Somebody" unless $me;
-
- print "Enter the message to broadcast. End with ^D.\n" if -t STDIN;
- for (;;) {
- print ">> ";
- $_ = <STDIN>;
- unless (defined($_)) {
- print "<EOF>\n" if -t STDIN;
- last;
- }
- chop;
- push(@MSG, "$_ \r\n");
- }
- unless (@MSG) {
- print stderr "wall: no message.\n";
- exit;
- }
- unshift(@MSG, "\007\r\nBroadcast Message from $me: \r\n");
-
- open(WHO, "who|");
- while (<WHO>) {
- chop;
- @F = split;
- $tty = $F[1];
-
- next if $tty =~ /^ttyp.$/;
-
- $TTY = "/dev/$tty";
- unless (-c $TTY) {
- print stderr "wall: $tty: no such device\n";
- next;
- }
- unless (open(TTY, ">> $TTY")) {
- print stderr "wall: can't open /dev/$tty: $!\n";
- next;
- }
- print TTY @MSG;
- close(TTY);
- }
- close(WHO);
-