标题: 大家帮忙看一道题 [打印本页] 作者: biaog 时间: 2006-08-29 11:14 标题: 大家帮忙看一道题 Write a shell script (to run on the Bourne shell) that runs an infinite loop to check every 5 seconds to report on who logs into and who logs out of a UNIX system. Without loss of practical significance of this little utility, we can ignore multiple logins from the same user during a time period of less than 5 seconds.
You would need to research these UNIX commands: cut, sort, cmp.
Your script for this task must be named log.sh. The following is a sample output of the script (It is OK that the script leaves behind a temporary file when it is finally interrupted). The $ is the shell prompt.
$ log.sh
The current users are:
abc1
rv0
sxu
tgray
No user has logged in/out in the last 5 seconds.
No user has logged in/out in the last 5 seconds.
User rsmith has logged in.
No user has logged in/out in the last 5 seconds.
User abc1 has logged out.
No user has logged in/out in the last 5 seconds.
… … … … … … … …