trap : 1 2 3
echo ""# skip a line
cat /etc/motd
trap "" 1 2 3
}# setting default attributes for terminal moved to ~/.profile, so
# each user has individual control over these characteristics# if not doing a hushlogin, check mailbox and news bulletins
if [ "X$HUSHLOGIN" != "XTRUE" ]
then
[ -x /usr/bin/mail ] &&{# if the program is installed
[ -s "$MAIL" ] &&
dspmsg $MF_ADM -s $MS_PROFILE $MSG_MAIL "nyou have mailn"
}
if [ "$LOGNAME" != "root" -a -x /usr/bin/news ]# be sure it"s there
then news -n
fi
fi
-su)
:
esac#trap 1 2 3lab=0
name=`who am I | awk "{print $1}"`
dev=`who am I | awk "{print $2}"`config_file=/etc/logport/loginfo
if [ ! -r $config_file ]
then
echo "没有 $config_file 文件,请与系统管理员联系 "
exit 1
fi#get line of config: guest tty63e 1234567 08 00 12 00
config_detail=`cat $config_file|grep $dev`
#echo $config_detail
#check detail, -z 检查变量是否存在, 长度为零返回真
if [ -z "$config_detail" ]
then
echo "没有设置用户和用户登录时间限制参数!"else
config_user=`echo $config_detail|awk "{print $1}"`
config_term=`echo $config_detail|awk "{print $2}"`
config_week=`echo $config_detail|awk "{print $3}"`
config_start_hour=`echo $config_detail|awk "{print $4}"`
config_start_min=`echo $config_detail|awk "{print $5}"`
config_end_hour=`echo $config_detail|awk "{print $6}"`
config_end_min=`echo $config_detail|awk "{print $7}"`
#echo "config_user=" $config_user
#echo "config_term=" $config_term
#echo "name=" $name
#echo "dev=" $devif [ $config_user != $name ]
then
echo "ntThe user $name can not login on this port"
echo "nt 对不起,用户 $name 不能登录此端口"
echo "nt *********************************"
exit 1
elseww=`date%w`
# 得到当前星期几
aa=`date%H`
# 得到当前时间的时值
bb=`date%M`
# 得到当前时间的分值
hm=`expr $aa * 60$bb`
# 把当前时间化成分值
lab=0
awk -v hm1="$hm" -v ww1="$ww""$3 !~ ww1 {exit 1} {stime=$4*60 $5; etime=$6*60 $7} {if(hm1< stime || hm1>etime) {exit 1}}" /etc/logport/loginfo || lab=1
if [ $lab -eq 1 ]
# 如果不在工作时间内登录则退出
then
echo "nt You must login in working time"
echo "nt 对不起,您必须在工作时间内登录此端口"
echo "nt ************************************"
exit 1
fifi
echo "nt 用户 $name 登录此端口"
echo "nt 您的工作时间为 $config_start_hour时 $config_start_min分 至 $config_end_hour时 $config_end_min分"
echo "nt ********************************************"fi
#awk -v name1="$name" -v dev1="$dev""$1 == name1 && $2 != dev1 {exit 1}" /etc/logport/loginfo || lab=1
#if [ $lab -eq 1 ]
# 和信息配置表中相应字段对比
#then
#echo "ntThe user $name can not login on this port"
#exit 1
#fitrap 1 2 3在/etc目录下建立一个logport目录,将loginfo文件放入其中
loginfo文件内容解释如下
用户名 所登录的端口名 星期 开始登录时间 结束登录时间
root tty11 0123456 08 00 20 00
root tty01 0123456 07 00 23 00
root tty02 0123456 07 00 23 00
liaozp tty12 123456 08 00 20 00最后提醒大家要注意 loginfo文件的读的权限
推荐阅读
- 房屋租赁协议书如何写
- 微信音乐怎么下载
- 怎么找回微信聊天记录
- 辞职报告怎么写范文
- 双键合璧,掌握天下——东信ES1009
- 水产养殖病害的综合防治技术
- 魔酸与氢氧化铯混合会发生什么
- 什么叫铁碳合金相图
- 配合饲料的使用与鱼病的发生
- 微信运动98800步怎么刷
