0% found this document useful (0 votes)
5 views4 pages

Shell Script Menu for System Info

The document outlines a shell script that presents a menu for various system information and actions. Users can view the current month's calendar, receive greetings based on the time of day, and obtain details about the user, terminal, machine, and logged-in users. The script uses a case statement to execute the corresponding command based on the user's choice.

Uploaded by

for11trade
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

Shell Script Menu for System Info

The document outlines a shell script that presents a menu for various system information and actions. Users can view the current month's calendar, receive greetings based on the time of day, and obtain details about the user, terminal, machine, and logged-in users. The script uses a case statement to execute the corresponding command based on the user's choice.

Uploaded by

for11trade
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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";;

You might also like