#! /bin/sh
while true
do
who | cut -d " " -f1 | sort> old.txt
sleep 3
who | cut -d " " -f1 | sort> new.txt
comm old.txt new.txt -2 -3 >> logOneTime.txt
comm old.txt new.txt -1 -3 > newLog.txt
num=0
cat newLog.txt | while read line
do
if grep $line['-'] user.deny>/dev/null
then
if grep $line logOneTime.txt>/dev/null
then
fullName=`grep $line['-'] user.deny | cut -d "-" -f2`
num=`expr $num + 1`
echo -e "The user $fullName (on the denial list) has logged in more than once!\n"
fi
fi
done
if [ $num -eq 0 ]
then
echo -e "No user on the user.deny list has multiple logins\n"
fi
done
while true
do
shell脚本示例,运行无限循环的shell脚本来检测拒绝列表上的用户是否登录到UNIX系统多于一次。
最新推荐文章于 2024-07-27 10:34:09 发布