#!/bin/bash
#sh2.sh
temp="tempd"
#如果用户在线
isAt(){
echo $name
echo "用户在线,将写消息给$name,输入CTRL+D为结束"
echo `write $name`
# echo -e\n
# echo "welcom to this computer"
# echo "eof"
}
#如果用户不在线
isNoAt(){
echo "用户不在线,将写邮件给$name"
echo `mail $name `
echo -e\n
}
#判断用户是否在线
logins(){
echo "`who|cut -d ' ' -f 1 >temp;cat temp |grep $name >temps`"
`test -s temps`
cho=$?
echo ` rm temp*`
if [ $cho -eq 1 ];
then
echo "the man is NoAt"
isNoAt
else
echo "the man is At"
isAt
fi
}
cho(){
#if [ 0 -eq 0 ];
#echo "test -s temp/$temp"
`test -s tempd `
cho=$?
#echo "cho=$cho"
if [ $cho -eq 0 ];
then
logins #如果成立则
else
echo "You name is not regedit!"
fi
echo "bye"
}
echo "name:"
read name
`cat /etc/passwd |grep $name >$temp`
cho