hi.. this is shell scripting lab15.sh
i dont understand this lab i am at the screen shot part. i was wondering if someone can take a quick look at this lab i have linked the doc below. i dont know where to start
i have did the
Required Errorlevels
Errorlevel # but dont have the last one (19)
i no some error levels are wrong.(if [ $5 -gt 1 ]).
here is the lab 15 link below it will open online :
https://viewer.zoho.com/docs/k5Uuh --< lab15
this is my lab 14 now i have to add lab 15 into it i now the last part is wrong
# equal to 0
if [ $# -eq 0 ]
then
echo ""
echo "Error: No arguments present at all"
echo ""
echo "Usage: ./Lab_14.sh -i <infile> -o <outfile>"
echo " -i <infile> The filename containing the existing data."
echo " -o <outfile> The filename you want the output to go to."
echo ""
exit 10
fi
#first argument
if [ "$1" != "-i" ]
then
echo ""
echo "Error: Expecting \"i\" for the first argument"
echo ""
echo "Usage: ./Lab_14.sh -i <infile> -o <outfile>"
echo " -i <infile> the filename containing the existing data."
echo " -o <outfile> the filename you want the output to go to."
echo
exit 12
fi
#2argument
if [ "$2" = "" ]
then
echo ""
echo "Error: Second argument is missing."
echo "Usage: ./Lab_14.sh -i <infile> -o <outfile>"
echo ""
echo " -i <infile> The filename containing the existing data."
echo " -o <outfile> The filename you want the output to go to."
echo ""
exit 13
fi
#
if [ ! -e $2 ]
then
echo ""
echo "Error: File \"./input.txt\" does not exist."
echo ""
exit 14
fi
#3 argument
if [ "$3" = "" ]
then
echo ""
echo "Error: Third argument missing"
echo ""
echo "Usage: ./Lab_14.sh -i <infile> -o <outfile>"
echo " -i <infile> The filename containing the existing data."
echo " -o <outfile> The filename you want the output to go to."
echo ""
exit 15
fi
#
if [ "$3" != "-o" ]
then
echo ""
echo "Error: Expecting \"-o\" for the third argument."
echo ""
echo "Usage: ./Lab_14.sh -i <infile> -o <outfile>"
echo " -i <infile> The filename containing the existing data."
echo " -o <outfile> The filename you want the output to go to."
echo ""
exit 16
fi
#4 argument
if [ "$4" = "" ]
then
echo ""
echo "Error: Fourth argument missing."
echo ""
echo "Usage: ./Lab_14.sh -i <infile> -o <outfile>"
echo " -i <infile> The filename containing the existing data."
echo " -o <outfile> The filename you want the output to go to."
echo ""
exit 17
fi
#
if [ ! -e $4 ]
then
echo ""
echo "Message: file \"./output.txt\" does not exist already. Creating new file."
echo ""
echo "Correct amount of arguments provided ..."
echo ""
echo "First argument was: -i"
echo "Second argument was: ./input.txt"
echo "Third argument was: -o"
echo "Fourth argument was: ./output.txt"
echo ""
else
echo ""
echo "Message: File \"./output.txt\" exists already. Overwriting content."
echo ""
echo "Correct amount of arguments provided ..."
echo ""
echo "First argument was: -i"
echo "Second argument was: ./input.txt"
echo "Third argument was: -o"
echo "Fourth argument was: ./output.txt"
echo ""
fi
#to many arguments
if [ $# -gt 4 ]
then
echo ""
echo "Error: Too many arguments provided."
echo ""
echo "Usage ./Lab_14.sh -i <infile> -o <outfile>"
echo " -i <infile> The filename containing the existing data."
echo " -o <outfile> The filename you want the output to go to."
echo ""
exit 18
fi
#to many arguments 0 bigger the 0
if [ $5 -gt 1 ]
then
echo "Error: Too many arguments provided."
echo ""
echo "Usage ./Lab_14.sh -i <infile> -o <outfile>"
echo " -i <infile> The filename containing the existing data."
echo " -o <outfile> The filename you want the output to go to."
echo ""
echo "Previous process Errorlevel was: 18"
exit 19
else
echo ""
echo "Message: File \"./output.txt\" exists already. Overwriting contents."
echo ""
echo "Correct amount of arguments provided ..."
echo ""
echo "First argument was: -i"
echo "Second argument was: ./input.txt"
echo "Third argument was: -o"
echo "Fourth argument was: ./output.txt"
exit 19
fi
#end script