irv@entropy.ms.washington.edu@happym.UUCP (07/27/90)
Posting-number: Volume 14, Issue 34 Submitted-by: irv@entropy.ms.washington.edu@happym.UUCP Archive-name: wall-write/part01 #!/bin/sh # This is a shell archive (shar 3.21) # made 07/25/1990 21:56 UTC by irv@happym # Source directory /u/irv/src/util/irv # # existing files WILL be overwritten # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 1265 -rw-rw-rw- README # 1439 -rwxrwxrwx writei # 1342 -rwxrwxrwx walli # if touch 2>&1 | fgrep '[-amc]' > /dev/null then TOUCH=touch else TOUCH=true fi # ============= README ============== echo "x - extracting README (Text)" sed 's/^X//' << 'SHAR_EOF' > README && XWritei.sh is a substitute for /bin/write with enhancements: X X1. The message recipients are not bothered until the whole message Xhas been entered, whereas with write they are bothered before the Xmessage is ready. X X2. Multiple recipients are reached at every writeable terminal at Xwhich they have a login shell -- none of write's guessing and Xhoping for the best. X XWalli.sh is a substitute for /etc/wall that runs more smoothly in Xcrontab lines and at jobs. X XThey are nothing major, but we now use them to the total exclusion Xof wall and write, so they may be useful to someone else, too. X XBoth programs are slow shell scripts using lots of system Xutilities, rather than elegant C programs that do everything Xinternally. But they are easy to understand (and hence to modify Xif your preferences require it), and people with junk systems like XSCO UNIX that omit the C compiler can use them too. X XI tested both programs on two different flavors of System V UNIX, Xbut they may not work on anything else without changes. X-- X Irving Wolfe Happy Man Corp. irv@happym.wa.com 206/463-9399 ext.101 X SOLID VALUE, the investment letter for Benj. Graham's intelligent investors X Information (not sample) free: email patty@happym.wa.com with US mail addr. SHAR_EOF $TOUCH -am 0725145690 README && chmod 0666 README || echo "restore of README failed" set `wc -c README`;Wc_c=$1 if test "$Wc_c" != "1265"; then echo original size 1265, current size $Wc_c fi # ============= writei ============== echo "x - extracting writei (Text)" sed 's/^X//' << 'SHAR_EOF' > writei && X: X# @(#)writei.sh 1.4 - write to all terminals specified users are on, non-interactively X# MODIFIED 7/25/90 14:52:29 X# vi:se ts=4 wm=0 sw=4: X Xif test -x /etc/TIMEZONE Xthen X . /etc/TIMEZONE Xelif test -r /etc/TZ Xthen X TZ=`cat /etc/TZ` X export TZ Xelse X TZ=PST8PDT X export TZ Xfi XFILE=/usr/tmp/w$$i Xtrap "rm -f $FILE" 0 2 XDATE="`date`" XTTY="`tty`" XTTY="`basename $TTY`" XPROG=`basename $0` XSYS=`uuname -l` Xif test "$SYS" = "inkspot" Xthen X CUT=7 X PREFIX=\"tty\" Xelse X CUT=8 X PREFIX=\"\" Xfi X XTEMP="" Xfor i in $* Xdo X if egrep "^$i:" /etc/passwd >/dev/null 2>/dev/null X then X TEMP="$TEMP -u$i" X fi Xdone Xif test "$TEMP" Xthen X TEMP="`ps -f$TEMP | cut -c1-$CUT,33-80 | awk 'NR > 1 && $1 != "?" && $4 ~ /^-[rckgb]*sh$/ {print $1, '$PREFIX' $2}' | sort -u`" Xfi X Xif test "$TEMP" Xthen X if test -t 0 -a -t 1 X then X EOF=`stty -a | sed -n 's/^.*eof = \([^;]*\).*$/\1/p'` X echo "Terminate message with $EOF or ." X fi X awk " X BEGIN {printf \"\r%c\n%-79.79s\n%-79.79s\n\", 7, \ X \"$PROG from $LOGNAME ($TTY) [$DATE]\", \" \"} X \$0 ~ /^[.]$/ {exit} # stop for dot line X {printf \"\r%-79.79s\n\", \$0} X END {printf \"%c%-79.79s\n\", 7, \" \"} X " >$FILE X set $TEMP X if test -t 0 X then X while [ $# -gt 0 ] X do X echo "to $1 $2" X shift 2 X done X set $TEMP X fi X while [ $# -gt 0 ] X do X if test -c "/dev/$2" -w "/dev/$2" X then X cat $FILE >>/dev/$2 X fi X shift 2 X done Xelif test -t0 Xthen X echo '\007' >&2 X echo $PROG: no one to send to >&2 Xfi SHAR_EOF $TOUCH -am 0725145290 writei && chmod 0777 writei || echo "restore of writei failed" set `wc -c writei`;Wc_c=$1 if test "$Wc_c" != "1439"; then echo original size 1439, current size $Wc_c fi # ============= walli ============== echo "x - extracting walli (Text)" sed 's/^X//' << 'SHAR_EOF' > walli && X: X# @(#)walli.sh 1.4 - substitute for /etc/wall that works with crontab and at X# MODIFIED 7/25/90 14:52:24 X# vi:se ts=4 wm=0 sw=4: X Xif test -x /etc/TIMEZONE Xthen X . /etc/TIMEZONE Xelif test -r /etc/TZ Xthen X TZ=`cat /etc/TZ` X export TZ Xelse X TZ=PST8PDT X export TZ Xfi XFILE=/usr/tmp/w$$a Xtrap "rm -f $FILE" 0 2 XDATE="`date`" XTTY="`tty`" XTTY=`basename $TTY` XPROG=`basename $0` XSYS=`uuname -l` Xif test "$SYS" = "inkspot" Xthen X CUT=7 X PREFIX=\"tty\" Xelse X CUT=8 X PREFIX=\"\" Xfi X Xif test -t 0 -a -t 1 Xthen X EOF=`stty -a | sed -n 's/^.*eof = \([^;]*\).*$/\1/p'` X echo "Terminate message with $EOF or ." Xfi X XTEMP="`ps -ef | cut -c1-$CUT,33-80 | awk 'NR > 1 && $1 != "?" && $4 ~ /^-[rckgb]*sh$/ {print $1, '$PREFIX' $2}' | sort -u`" X Xif test "$TEMP" Xthen X awk " X BEGIN {printf \"\r%c\n%-79.79s\n%-79.79s\n\", 7, \ X \"$PROG from $LOGNAME ($TTY) [$DATE]\", \" \"} X \$0 ~ /^[.]$/ { exit } # stop for dot line X {printf \"\r%-79.79s\n\", \$0} X END {printf \"%c%-79.79s\n\", 7, \" \"} X " >$FILE X if test -t 0 X then X echo 'sending to:' X fi X set $TEMP X while [ $# -gt 0 ] X do X if test -c "/dev/$2" -t 0 X then X echo " $1 $2" X fi X shift 2 X done X set $TEMP X while [ $# -gt 0 ] X do X if test -c "/dev/$2" -w "/dev/$2" X then X cat $FILE >>/dev/$2 X fi X shift 2 X done Xelif test -t0 Xthen X echo '\007' >&2 X echo $PROG: no one to send to >&2 Xfi Xexit 0 SHAR_EOF $TOUCH -am 0725145290 walli && chmod 0777 walli || echo "restore of walli failed" set `wc -c walli`;Wc_c=$1 if test "$Wc_c" != "1342"; then echo original size 1342, current size $Wc_c fi exit 0 -- Irving Wolfe Happy Man Corp. irv@happym.wa.com 206/463-9399 ext.101 SOLID VALUE, the investment letter for Benj. Graham's intelligent investors Information (not sample) free: email patty@happym.wa.com with US mail addr.