I need help with 2 problems for Unix... 1. Write a shell script named mychmod th
ID: 3766344 • Letter: I
Question
I need help with 2 problems for Unix... 1. Write a shell script named mychmod that takes two arguments, a filename and permission specification, then changes the user permissions to the filename based on the permission specification. The permission specifications may be readonly, readwrite, or readwriteexec. Permissions for group and other should be all disallowed. A usage statement should be printed if two arguments are not provided, or the permission specification is not one of the above. You should also report if the filename provided does not exist. 2. Write a menu driven shell script program named sysstats that will allow a user to view system resources by specifying the following options: 1) show a listing of processes of that terminal window or command line; 2) List all processes in the system; 3) Show the system “uptime” information; 4) Show the system process and resource information with “top”; 5) Exit the menu. (hint: this can be implemented with a case structure)
This is what I have so far for the first one
#!/bin/bash
#Check if filename exists
file= "~/mychmod" if[-f "$file"];
then echo "$file found"
else echo "$file not found"
fi
if [[ Permission = *00 ]]; then
chmod $Permission $FileName
else
echo "This is not a valid permission for this program."
fi
Explanation / Answer
code for first:
#!/bin/bash
#Check if filename exists
file= "~/mychmod" if[-f "$file"];
then echo "$file found"
else echo "$file not found"
fi
chmod a+rwx "$file"
2)
working script for second part.
Please psate the required commands as per option accordingly
#!/bin/sh
option="${1}"
case ${option} in
1)
echo "command one"
;;
2)
echo "command two"
;;
3)
echo "command three"
;;
4)
echo "command three"
;;
5)
exit
;;
esac
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.