Question: I created script 1 and script 2 shown below. I've tested them and they work. I'm stumped on creating script 3! Creating shell script 1.

I created script 1 and script 2 shown below. I've tested them and they work. I'm stumped on creating script 3!

Creating shell script 1.

#!/bin/bash

CURRENT=$(df / | grep / | awk '{ print $5}' | sed 's/%//g')

THRESHOLD=$1

#

if [ "$CURRENT" -gt "$THRESHOLD" ] ; then

echo WARNING-Root partition space low Used: $CURRENT% >> ~/systemlog

fi

Script 2

#!/bin/bash

if [ -e $1 ]

then

echo file $1 does exist

else

echo file $1 does not exist

exit 1

fi

if [ -d $1 ]; then

echo n $1 is a directory that you may

if [ ! -x $1 ]; then

echo n not

fi

echo n search.

elif [ -f $1 ]; then

echo $1 is a regular file.

else

echo $1 is a not of type directory or file

fi

Creating shell script 3.

  1. Now that you are becoming familiar with bash scripting enhance script 1 to do these items:
  • Require the script to now use (2) parameters that are passed in.
  • Check for the number of parameters passed in and if it is not 2, display an error message and exit.
  • The second parameter will represent a value for the minimum amount of available memory (IE: 200000).
  • Parse the output from the vmstat or free command for the amount of free memory. Lets call this the free_value. Compare free_value to the value passed in for parameter 2. If free_value is less than parameter 2 issue a warning message that will be written to ~/systemlog.

  1. Test to make sure your script3 works properly by passing these test case parameters:

$ ./script3

$ ./script3 10

$ ./script3 10 800000

$ ./script3 90 200000

$ ./script3 90 800000

$ cat /~/systemlog

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!