Consider this script file named 6hw, the information shown about it, and its con
ID: 663821 • Letter: C
Question
Consider this script file named 6hw, the information shown about it, and its contents. There are five reasons why this script will either refuse to run or will throw errors. Name each of the five things wrong, and what you would do, specifically to correct each one (if there's a command you would use to correct it, show the full command; if there's a change that needs making in the script, just say what is wrong and what you would change it to). Assume that you are the file's owner and the group shown is your group:
-rw-r--r-- 1 yourname yourgroup 203 Jan 27 20:36 6hw
The contents of the file:
!/bin/bash
echo "Please state your name."
read name
if [ "$moniker" = "Horatio" ]
then
echo Welcome to the Internet, $name!
else
echo "You are not Horatio, $name, but there's room enough for us all."
Explanation / Answer
Error 1:
The execute permission for the file 6hw is not set. To correct it, enter the following command : chmod +x 6hw
Error 2:
# is missing. To make it a bash script, add a # in the beginning of the first line: #!/bin/bash
Error 3:
fi is missing at the end of the if block. Add 'fi' after the last line
Error 4:
In the if condition, we have to put $name in place of $moniker: if [ "$name" = "Horatio" ]
Error 5:
Welcome to the Internet, $name! should be in double quotes: "Welcome to the Internet, $name!"