Question

Write a shell script to solve the following business problem. Create a file called whoislogin.out...

Write a shell script to solve the following business problem. Create a file called whoislogin.out that contains the output of the who command, then append to the whois.out file, the output of the date and finger commands. Your script should prompt to pick any users from the list of users currently logged onto the system. Use the variable concept to search for the specific user from those displayed on the screen coming from the who is.out file created. Show a print screen of your solution and output. (psql)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

NOTE: I have completed answers for your question along with explanation. Please check and let me know if you have any questions. I will revert back within 24 hours. Thanks for your patience.

Code:
#!/bin/bash

# writing who command output to whoislogin.out
who > whoislogin.out

# writing date and finger commands output to whois.out
date > whois.out
finger >> whois.out

# appending contents of whoislogin.out to whois.out file
cat whoislogin.out >> whois.out

# asking the user want to search
echo "Enter the username you want to search? "
read usrname

# searching for the user in whois.out file
echo "'$usrname' available in logged in users are"
grep $usrname whois.out


Code output screenshot:

Unix Terminal> bash test.sh Enter the username you want to search? vishal vishal available in logged in users are vishal gr

Add a comment
Know the answer?
Add Answer to:
Write a shell script to solve the following business problem. Create a file called whoislogin.out...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. Write the command to set the following permissions on a script file with the following...

    1. Write the command to set the following permissions on a script file with the following name; myscript.sh Owner: full access; read, write and execute Group: read and execute Other: no access 2. Create a new file with the name "myfirstscript.sh". Write a new script that performs the following tasks in sequence; Display the usernames of currently logged in users; sorted from a-z HINT: You will need to filter the output of the whocommand Display a list of usernames who...

  • Exercise 1: Write a shell script that loops through the /etc/passwd file one line at a...

    Exercise 1: Write a shell script that loops through the /etc/passwd file one line at a time. Prepend each line with a line number followed by a colon and then a space. Example output: 1: root:x:0:0:root:/root:/bin/bash 2: daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin 3: bin:x:2:2:bin:/bin:/usr/sbin/nologin 4: sys:x:3:3:sys:/dev:/usr/sbin/nologin Exercise 2: Write a shell script that asks the user for the number of lines they would like to display from the /etc/passwd file and display those lines. Example output: How many lines of /etc/passwd would you like...

  • In UNIX Write a script that checks each minute and reports on who logs in and...

    In UNIX Write a script that checks each minute and reports on who logs in and who logs out. You can follow the steps below (not the only way): Using the commands who and cut, extract the list of usernames currently logged in the system To check after a minute, the sleep command can be used: sleep 60 Get the new list of users logged in after a minute For each user in the list; check if he is in...

  • I need this done ASAP. Please write a bash shell script that does the following: Prints...

    I need this done ASAP. Please write a bash shell script that does the following: Prints out how many users are logged on. This can be accomplished using who and wc. Prints out a list of currently logged on users. This can be accomplished using who, grep, regular expressions, and echo. Prints out how many processes you have running from past days, and a list of those jobs. Use `whoami` to get your username. Run ps -ef and see how...

  • You will create a shell script that prints out the following information about the system it is run on: • The system’s n...

    You will create a shell script that prints out the following information about the system it is run on: • The system’s name and IP address • How much memory the system is currently using, and how much total memory it has • The number of CPUs of the machine • The number of unique users on the system at that moment When your script is run, each of these values should be clearly labeled in the output, such as...

  • Write a shell script called GetMyStuff.sh that will provide the above information (the script must be...

    Write a shell script called GetMyStuff.sh that will provide the above information (the script must be a executable, and must work regardless of which directory it is in). Also, just saying cat MyStuff.txt is not sufficient. (1.0%) A pipeline is the combination of at least 2 commands, where the output of command1 is the input for command2. The syntax is command1 | command2 where | is the pipeline operator. Read the man pages about the ls and wc commands. Devise...

  • Write a SHELL SCRIPT: Write a simple shell that is similar to what we have discussed...

    Write a SHELL SCRIPT: Write a simple shell that is similar to what we have discussed in class. while (1) {//repeat forever type_prompt();//display prompt on screen read_command (command, parameters);//read input from terminal if (fork() != theta)//parent wait (NULL);//wait for child else{execve (command, parameters, theta);//execute command}} but contains enough code that it actually works so you can test it. For simplicity, you may assume that all commands are in the directory/bin.

  • Open vi or pico and create a script called Information.   Add the contents from the following table to the script: (Hin...

    Open vi or pico and create a script called Information.   Add the contents from the following table to the script: (Hint: use echo to add blank lines to your output and to write out the headings). Headings: Utilities (command to execute) Today’s date is: date The current users logged on to the system are: who My current startup directory is: pwd Today’s identification information is: id The processes running on my system are: ps Add a header to your Information...

  • (In Linux) 1. Create a file to write to from your script and save it as...

    (In Linux) 1. Create a file to write to from your script and save it as “.txt”. 2. Write the following information to the file that you created in Step 1: Today's date Your full name Your student ID The name of your course What directory you are in File permissions of the file that you created that allow everyone to read, write, and execute The long list of files in your current directory, providing all items and their process...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT