Hall H.

asked • 02/25/21

Linux Assignment Urgent Help

INSTRUCTIONS

These three activities are three little shell programs to create and review, one called svi.sh and the other uon.sh, the other is the command_menu program at the bottom of page 456. Your job is to explain what certain lines of the shell program do. The last part of this lab is to create the command_menu program. On the first two programs add your comments about what those lines of the code do after the # symbol, describing briefly what that particular piece of code will do in the program.  

These are the three files to submit in the same dropbox. Type them in vi, and replace the ???? with your comments explaining what those lines do in the program. The last command_menu program you will need to create it and run it a few times, make sure to change the ie. “a) date” with other commands or options just to try it out and make it different than the book.



#1


name@domain:~> cat svi.sh

#!/bin/bash

# name / date ?????????????????          

# purpose of the program ????????????????

 

if test $# = 1 # ???                       

  then

if test -f $1 # ???       << the lines that starts with # or in this case after the command #??? bash ignores them, the # except $# that is a command.

then

cp $1 $HOME/keep #???    <<< your job is to replace the ??? with your comment indicating what that lines does in the program

vi $1

else

echo " file not found.Try again"

fi

else

echo " You must specify a file name.Try again."

fi


#2


For the first two comment lines, your name and date

#!/bin/bash

# Your Name

# Date

The lines that contain #... are comments to the program, Replace the ??? with your comments explaining what happens in that line of the program. Submit the program with your name using the following command:

name@domain:~> cat uon.sh                  

#!/bin/bash

#uon.sh: this program will ????????

until who | grep "$1" > /dev/null #??????????

do sleep 30 #??????????

done

echo "$1 is logged on." exit 0


#3

Create the program on page 456 4th edition called command_menu. Run it a few times, change options, etc.


$ cat command_menu

#! /bin/bash

# menu interface to simple commands


echo -e "\n" COMMAND MENU\n"

echo " a. Current date and time"

echo " b. Users currently logged in"

echo " c. Name of the working directory"

echo - e " d. Contents of the working directory\n"

echo -n "Enter a, b, c, or d: "

read answer

echo




1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.