#!/bin/sh # .quit, .who, ;, .time echo "+++ hello +++ welcome to the sh talker +++ +++ what's your name ?" cd `dirname $0` if [ ! -d users ]; then mkdir users fi cd users read X X=`echo $X | sed 's/ $//'` echo "+++ welcome, $X" for USER in * ; do if [ -w "$USER" ]; then echo "+++ $X has connected" >> $USER fi done touch $X read Y while [ ".quit " != "$Y" ] ; do case "$Y" in ".who ") ls | sed 's/^/+++ /';; ".time ") date | sed 's/^/+++ /';; \;*) Y=`echo $Y|sed 's/^.//'` for USER in * ; do if [ -w "$USER" ]; then echo "$X $Y" >> $USER fi done;; *) for USER in * ; do if [ -w "$USER" ]; then echo "$X :$Y" >> $USER fi done;; esac cat $X rm $X touch $X read Y done echo "+++ bye then" rm $X for USER in * ; do if [ -w "$USER" ]; then echo "+++ $X has disconnected" >> $USER fi done if [ ! -f * ]; then cd .. rmdir users fi