#! /bin/sh TTYS=`who | grep $USER | tr -s ' ' | cut -d' ' -f2 | grep -v :` if [ -z "$1" ]; then if ! tty > /dev/null; then echo "stdin is not a tty" >&2 exit 1 fi HERE=`tty` elif [ -c "$1" ]; then HERE=$1 elif [ -c "/dev/$1" ]; then HERE=/dev/$1 else echo "No such device: $1" exit 1 fi BASEHERE=`echo $HERE | sed 's|^/dev/||'` if [ -c $HERE ] && echo $TTYS | grep '\<'$BASEHERE'\>' > /dev/null; then for tty in $TTYS; do [ "$BASEHERE" != "$tty" -a -c /dev/$tty ] && chmod g-w /dev/$tty; done chmod g+w $HERE else echo "You are not logged in on $BASEHERE" >&2 fi