bash assignment

The bash assignment consists of 3 parts. Each part will contribute to the total assignment mark. The rubric and submission for this assignment is on blackboard.

To get full marks for any script, your scripts must have the following elements as covered in class:

script interpreter line

command line processor using while, shift, and case if the script allows command line options or arguments

comments describing the script

error messages going to stderr

correct exit status

Add command line arguments to a script

The following script fragment will roll virtual dice and show what was rolled and what the total rolled was.

sum=0

while [ $count -gt 0 ]; do

roll=$(( $RANDOM % $sides +1 ))

sum=$(( $sum + $roll ))

echo "Rolled $roll"

count=$((count - 1))

done

echo "You rolled a total of $sum"

This script expects two variables to be defined before it runs.

count should contains the number of dice to roll

sides should contain the number of sides each die should have

Modify the script to allow the user to run the script without any command line arguments which will cause it to roll a pair of 6-sided dice.

Accept the following command line options:

-h or --help should display command line syntax and exit successfully

-c N or --count N should set the count of dice to roll to N, N must be a number from 1 to 9

-s N or --sides N should set the number of sides per die to N, N must be a number from 4 to 20

Display an error message and exit with a failed status if the user puts bad input on the command line.

Memory Usage Report

Create a simple but human friendly report on memory usage. You can use the free command to get the data for your report.

Display a report title

Display the total amount of RAM installed and the amount of free RAM

Calculate and display the sum of the used and cached RAM

Calculate and display the difference between the available and free amounts

Calculate and display how much RAM is shared as a percentage of the RAM used

Calculate and display how much RAM is used as a percentage of the total RAM

Calculate and display how much RAM is used for cache as a percentage of the total RAM

Your report should have a title. Each output data item should be appropriately labelled and scaled to display in megabytes. No command line options or arguments are required for this script.

Command Source Identification

Create a simple script that asks a user for command names, then tells them which software package the command comes from if it comes from a package that is installed on the system. You can use the dpkg -S filepath command to identify the software package.

If the user gives no command names as arguments on the command line, ask them for a command name, identify the source according to the rules below, and then ask for the next command name in a loop

If the user gives you one or more command names as arguments on the command line, identify sources for them instead of asking for file names

Accept a command line help option to display command help

Rules for identifying the source of a command name:

If the user just hits enter when asked for a command name, exit successfully

If the user gives a non-existent command name, give them an error message and move on to the next command name

If they give you a command name that didn’t come from a software package, tell them that it didn’t and tell them the full pathname of the file containing the command and who owns that file

If they give you a command name that doesn’t come from a file, tell them and move on to the next command name

Hi,
Looks like this is an assignment work. I can write a bash script for your requirement. But would like to know when you need. I cannot write in 5 or 10 hours as i already have some project ongoing. If you give meFlere

Hello,
I have done this script earlier and can provide the answer now.
You can check the script and pay. I have also done the scripts "Add command line arguments to a script" and "Command Source Identification" Flere

hello,how are you. i read your bid carefully.
i am c/c++, linux expert and have full experience for 10 years.
c/c++, linux is my top skill and i can complete your project by using c/c++, linux.
i can provide most quFlere

I am a programmer who did a lot of programming for fun during my nerd years, before I actually came to college. During that time I read a lot about bash scripting, and I think I can easily do this task.
As proof of coFlere

This is a good opportunity to write an well documented script to meet your needs. It should not be rushed and it should be awarded to someone dedicated to quality and that knows how to deliver clean scripts. I am sure Flere