Tuesday, May 30, 2006

Bash Script - Case Statement

Heres a case statement I wrote to check current users logged in,
what they are doing etc ...

[root@localhost Bash]# cat case.sh
#!/bin/bash

echo "1 - Shows a listing of currently logged-in users "

echo "2 - Shows who is logged on and what they are doing "

echo "3 - Shows a list of last logged-in users, including login time,
logout time, login IP address, etc"

echo " 4 - Same as last, except that by default it shows a log of the
file /var/log/btmp, which contains all the bad login attempts."

echo " 5 - This reports data maintained in /var/log/lastlog,
which is a record of the last time a user logged in."

echo "6 - Exit Menu"

echo "Enter your Options "
read e;

case $e in

1) who ;;
2) w ;;
3) last ;;
4) lastb ;;
5) lastlog ;;
6) exit;;

*) echo "$e Opps Option not available, Please choose between 1 to 5"

esac


Save the file and exit

No comments: