Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is for shellscript The text: enter username to find. The program then takes

ID: 3918965 • Letter: T

Question

This is for shellscript

The text: enter username to find. The program then takes user input from the command line and checks to see if the user that the person entered exists on the system. If the user does not exist, the script sends an error message that says "try again or type exit to quit". If the user types exit the program will terminate. If the user does exist on the system (all users are located in /etc/passwd), the program will finger the user and returns the information to the screen. Once the successful user was found the program will exit normally. If the user is not found the program will loop until the user either types exit or successfully enters a user name.

Explanation / Answer

Hi,

I wrote a bash script , if you have any doubts , feel free to leave in comments and make sure to leave a thumbs up.

#!/bin/bash

while [ 1 ]

read user

do

if [ $user == 'exit' ] ; then

exit 1

elif [ $(getent passwd $user) ] ; then

finger $user

exit 1

else

echo "try again or type exit to quit"

fi

done

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote