Shell 编程 2

#!/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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值