안녕하십니까?
스크립트를 짜다가 막히는 부분이 있어서 이렇게 질문을 합니다.
아래에 보이는 스크립트는 로그인과 로그아웃을 자동으로 감지해서 화면에
아이디와 터미널, 그리고 시간을 표시해주는 스크립트입니다. 다른부분은
다 잘 되는데 가장 중요한 로그인과 로그아웃부분에 표시가 안되네요.
무엇이 문제인지...
혹시 아시는분은 답변주시면 감사하겠습니다.
# This script was made by Soonchul Kwon (skwon01).
# The name of this script is wd.
#
# This script checks users who log in and log out every
# ten second and displays updated status which include
# users' names, Terminals, and Time.
#!/bin/ksh
. .ksh_lib
clear
BBLUE ; BOX 1 1 20 39 . ; RESET
BBLUE ; BOX 1 41 20 79 . ; RESET
BBLUE ; BOX 22 1 24 79 . ; RESET
LOCATE 2 14 ; BRED ; echo "Log In Window" ; RESET
LOCATE 2 53 ; BRED ; echo "Log Out Window" ; RESET
LOCATE 4 2 ; BCYAN ; echo "Name Terminal Time "
LOCATE 4 42 ; BCYAN ; echo "Name Terminal Time "
LOCATE 23 2 ; BRED ; echo "Number of Users : " ; RESET
pos1=5
pos2=5
blk=" "
name=`cat .hid | awk -F"|" '{print $2}'`
terminal=`cat .hid | awk -F"|" '{print $3}'`
time1=`cat .hid | awk -F"|" '{print $6,$7,$8}'`
time2=`cat .hid | awk -F"|" '{print $6,$7,$8,$9,$10}'`
reform=`cat .diff_file | tr -s ' ' '|'`
comp1=`cut -c1 .hid`
comp2=`awk -F"|" '{print $11}' .hid`
comp3=`awk -F"|" '{print $9}' .hid`
last -100 -R > info1
while true ; do
sleep 10
last -100 -R > info2
number_users=`who | cut -c1-8 | sort -u | wc -l`
diff info1 info2 > $HOME/.diff_file
if [ -s $HOME/.diff_file ] ; then
for mark in $reform ; do
echo $mark > $HOME/.hid
if [ $comp1 = ">" -a $comp2 = "logged" ] ; then # <= 요부분이 문제인것 같은데...
if [ $pos1 -ne 15 ] ; then
LOCATE pos1 2 ; FYELLOW ; echo "$name $terminal $time1" ; RESET
(( pos1 = pos1 + 1 ))
else
ere=5
while [ $ere -eq 16 ] ; do
LOCATE $ere 2 echo $blk
(( ere = ere + 1 ))
done
pos1=5
fi
else
if [ $comp3 = "-" -a $comp1 = ">" ] ; then # <= 요부분도 이상한 것 같고...
if [ $pos2 -ne 15 ] ; then
LOCATE $pos2 42;FYELLOW;echo "$name $terminal $time2";RESET
(( pos2 += 1 ))
else
ere=5
while [ $ere -eq 16 ] ; do
LOCATE $ere 2 echo $blk
(( ere += 1 ))
done
pos2=5
fi
fi
fi
done
fi
cp /dev/null .diff_file
cp info2 info1
LOCATE 23 20 ; BYELLOW ; echo $number_users ; RESET
done
#############################.ksh_lib###########################
####################################aliases###################################
alias -x CLS='printf "