A6: Displaying operating system name, version, login name and hostname.
->Program:
#This program uses the system commands to display the required information.
while true
do
echo "1.Display Operating System name :";
echo "2.Display Operating System Version:";
echo "3.Display Login name :";
echo "4.Display Hostname :";
echo "5.Exit";
echo "Enter your choice : ";
read ch;
case $ch in
1)
echo " Operating System Name : ";
uname #displays operating system name
;; # to break first switch case
2)
echo "Operating System Version : ";
cat /proc/version #cat command reads the file /proc/version and displays the
;;
3)
echo "Login Name : ";
who #displays the names of all logged in users
;;
4)
echo "Host Name :"
hostname #displays the hostname
;;
5)
echo "exit from program "
exit;
;;
esac # end of switch case
done
OUTPUT:-
content of the file
[joker415@localhost Some-BashScripts-For-practice]$ ls
A-1.sh A-2.sh A-3.sh A-4.sh A-5.sh A-6.sh
[joker415@localhost Some-BashScripts-For-practice]$ chmod 777 A-6.sh
[joker415@localhost Some-BashScripts-For-practice]$ ./A-6.sh
1.Display Operating System name :
2.Display Operating System Version:
3.Display Login name :
4.Display Hostname :
5.Exit
Enter your choice :
1
Operating System Name :
Linux
1.Display Operating System name :
2.Display Operating System Version:
3.Display Login name :
4.Display Hostname :
5.Exit
Enter your choice :
2
Operating System Version :
Linux version 3.11.10-301.fc20.x86_64 (mockbuild@bkernel01.phx2.fedoraproject.org) (gcc version 4.8.2 20131017 (Red
Hat 4.8.2-1) (GCC) ) #1 SMP Thu Dec 5 14:01:17 UTC 2013
1.Display Operating System name :
2.Display Operating System Version:
3.Display Login name :
4.Display Hostname :
5.Exit
Enter your choice :
3
Login Name :
joker415 :0 2015-09-05 09:08 (:0)
joker415 pts/0 2015-09-05 09:11 (:0)
1.Display Operating System name :
2.Display Operating System Version:
3.Display Login name :
4.Display Hostname :
5.Exit
Enter your choice :
4
Host Name :
localhost.localdomain
1.Display Operating System name :
2.Display Operating System Version:
3.Display Login name :
4.Display Hostname :
5.Exit
Enter your choice :
5
exit from program
0 comments:
Post a Comment