Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In this assignment, there are 2 problems. 1st picture is - problem 1 2nd picture

ID: 3819686 • Letter: I

Question


In this assignment, there are 2 problems.
1st picture is - problem 1 2nd picture is - problem 2
Please make sure the coding solution is clear as possible. Also, after you finish the coding, can you please provide the commands you use to check if the coding is right or working. In this assignment, there are 2 problems.
1st picture is - problem 1 2nd picture is - problem 2
Please make sure the coding solution is clear as possible. Also, after you finish the coding, can you please provide the commands you use to check if the coding is right or working. The goal of this problem is to write a script to remediate the shortcomings of rm and rmdir. You will write a script that allows user to pass to it, as positional parameter(s), file(s) or directoriy(ies) and stores them in a specific location on your filesystem before removing them permanently from their current locations Your script should Check if a directory Trash exists under the Root directory (ie, check ifITrash exists on the computer the scripts is running) If yes, do nothing If no, create it and check if it was successfully created (check for the return value of the command that creates a new directory) (i) Take as an input name(s) of the file(s) and/or directory(ies) If no argument (file name) was passed, warn a user that no argument was passed and exit with a non-zero status If at least one argument was passed, check if it(they) is(are) simple file(s), directories, or others if passed argument is not representing the file or directory, warn the user that no valid argument was received and exit with a non-zero status if the argument represents a valid file, copy the files to the ITrash directory and "permanently remove it from its initial location if the argument represents a valid directory, copy the directory and all its content (subdirectories and/or files it contains) to the rash directory and permanently remove the directory from its initial location For example, assume that your script is named my script.sh. If a user invokes it by typing my script.sh file name, your script (i.e., my script.sh) should: check if ITrash exists and creates it if not, (i) check if file name is a simple file, or directory, or neither, and (iii) if the file name is a file or directory, copy it to ITresh and remove from whenever it is now. Note that you have to check if file name represents a simple file or a directory since you need to use different commands to copy and del than directories. Also, note that if the directory to be deleted is not empty, you have to copy and remove the directo with all its content

Explanation / Answer

#!/bin/bash -l
#PBS -l nodes=4:ppn=8,walltime=24:00:00

cat $PBS_NODEFILE | uniq | tr '\012' ' ' > tmp-$PBS_JOBID
read -a NODE < tmp-$PBS_JOBID
rm tmp-$PBS_JOBID

inode=-1
ijob=0

usage() { echo "Usage: $0 [-s <45|90>] [-p <string>]" 1>&2; exit 1; }

while getopts ":s:p:" o; do
case "${o}" in
s)
s=${OPTARG}
((s == 45 || s == 90)) || usage
;;
p)
p=${OPTARG}
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))

if [ -z "${s}" ] || [ -z "${p}" ]; then
usage
fi

echo "s = ${s}"
echo "p = ${p}"


for ((K=1;K<=8;K++))
do
[ $((ijob++ % 2)) -eq 0 ] && ((inode++))
ssh ${NODE[inode]} _somepath_/RUN$K/sub.script &
done
wait
exit 0