Script No .
Definition:
Write a shell script to display the following menu and acts accordingly:
i. Calendar of the current month and year.
ii. Display “Good Morning/Good Afternoon/Good Evening” according tothe
current login time.
iii. User name, Users home directory.
iv. Terminal name, Terminal type.
v. Machine name.
vi. No. of users who are currently logged in; List of users who are currently logged
in.
Script:
echo "[Link] of the current month and year."
echo "[Link] "Good Morning/Good Afternoon/Good Evening" according to the current
login time."
echo "3. USer name, User home directory."
echo "[Link] name, Terminal type."
echo "[Link] name."
echo "[Link]. of users who are currently logged i list of users who are currently logged in."
echo "Enter your choice"
read ch
case $ch in
1) echo "Calendar of current month is "
cal;;
2) d=`date +"%H"`
if [ $d -lt 12 ]
then
echo "Good Morning"
elif [ $d -gt 12 -a $d -lt 16 ]
then
echo "Good Afternoon"
else
echo "Good Evening"
fi;;
3) echo "Username is $USER"
echo "Users Home directory is $HOME";;
4) echo "Terminal details"
tty;;
5) echo "Machine name is "
uname -m;;
6) echo "The number of users logged in are"
who | wc -l;;
*) "Invalid";;
OR
echo "[Link] of the current month and year."
echo "[Link] "Good Morning/Good Afternoon/Good Evening" according to the current
login time."
echo "3. USer name, User home directory."
echo "[Link] name, Terminal type."
echo "[Link] name."
echo "[Link]. of users who are currently logged i list of users who are currently logged in."
echo "Enter your choice"
read ch
case $ch in
1) echo "Calendar of current month is "
cal;;
2) d=`date +"%H"`
if [ $d -lt 12 ]
then
echo "Good Morning"
elif [ $d -gt 12 -a $d -lt 16 ]
then
echo "Good Afternoon"
else
echo "Good Evening"
fi;;
3) echo "Username is $USER"
echo "Users Home directory is $HOME";;
4) echo "Terminal details"
tty;;
5) echo "Machine name is "
uname -m;;
6) echo "The number of users logged in are"
who | wc -l;;
*) "Invalid";;