Question: Name the script isloggedon.sh The script should take 1 command line argument, which should be a username. This means you should run the command like
Name the script isloggedon.sh
The script should take command line argument, which should be a username. This means you should run the command like this:isloggedonsh usernameand your script will be able to get the username from the command line argument. You should NOT prompt the user to enter username after the script is running.
The script will check to see if the user exists on the system grep user etcpasswdIf the user does not exist it will print a message indicating that the user does not exist. Make sure you only get the line for the full username. For example, if the username is rbe you should not also get the rbet account.If you need help with this, ask
If the user does exist you will check to see if the user is currently logged on thewhocommand can be used to see who is currently logged on who grep userIf the user is logged on print a message that the user is logged on
If the user is not logged on use thelastlogcommand to find out the last time the user logged onPrint the username and the date and time of the last loginIf the user never logged on print that the user never logged on
Put comments in your script to include the script name, author, date created, and purpose.
Test and debug your script. Some test cases:
logged on user your user accountnot logged on user rbeif you are running the script on cntserv secteam if you are running the script on your server It is possible that I might be logged on while you are testing, but that is pretty unlikely unless you have asked me for helpuser that has never logged on binuser that does not exist blah
Once your script is complete create a directory in the homeexercisesabc directory called module on cntserv.Use your username for abc
Copyyour script into the homeexercisesabcmodule directory on cntserv.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
