Logo 
Search:

Unix / Linux / Ubuntu Articles

Submit Article
Home » Articles » Unix / Linux / Ubuntu » Homework HelpRSS Feeds

Write a menu driven program to display message, user name, terminal name, login date and time

Posted By: Matthew Evans     Category: Unix / Linux / Ubuntu     Views: 43707

Write a menu driven program for:
Display the message “Today is November 30,2005 and current time is 12:10:23”
Display the message “As of now 30 user are login to the system”
Display the message:
“ My details:-----
User name: MCA1001
Terminal name :tty01
Login date: _____
Login time: _____ “
Exit

Code for Write a menu driven program to display message, user name, terminal name, login date and time in Unix / Linux / Ubuntu

choice=0

while [ $choice -ne 4 ]
do
tput clear

echo "1. Today date and time"
echo "2. Total login user"
echo "3. My detail"
echo "4. Exit"
echo "Enter your choice"
read choice

if [ $choice -eq 1 ]
then
echo "Today is `date +%B` `date | cut -f 3 -d ""`, `date | cut -f 6 -d ""`"
echo " and current time is `date | cut -f 4 -d ""`"

elif [ $choice -eq 2 ]
then
echo "As of now `who | wc -l` user are login to the system"

elif [ $choice -eq 3 ]
then
echo "My details :-------"
echo "user name : `who i am | cut -f 1 -d ""`"
echo "Terminal name: `who i am | cut -f 4 -d ""`"
echo "Login date : `who i am | cut -f 12-13, -d ""`"
echo "Login time : `who i am | cut -f 14 -d ""`"
fi
echo "Are you continue (1 for yes/0 for n)"
read temp

if [ $temp -eq 0 ]
then
        choice=4
fi
done
  
Share: 



Matthew Evans
Matthew Evans author of Write a menu driven program to display message, user name, terminal name, login date and time is from London, United Kingdom.
 
View All Articles

 

Other Interesting Articles in Unix / Linux / Ubuntu:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!