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

I created the following code with that instructions A. How Make a shellScript na

ID: 3739556 • Letter: I

Question

I created the following code with that instructions

A. How Make a shellScript named ExShell.sh to create a menu with the following options :

Search for a file and delete it
Create a directory called "repository",
Make an FTP from the server to your machine (client)
Make a reboot of your computer
Send the file to my email account
Exit

B. Clarifications of the menu:

In this directory you must copy ALL the files of this exam, including the "ExamShell.sh" script

C: FTP must be in line of commands.

CODE

#!/bin/bash
clear
date
while true
do

clear
date
echo
echo "-----------------------------------------------------------"

echo "1. Enter file name"

echo "-----------------------------------------------------------"

echo "2. Create a directory called "repository""

echo "-----------------------------------------------------------"

echo "3. Make an FTP from the server to your machine"

echo "-----------------------------------------------------------"

echo "4. Make a reboot of your computer"

echo "-----------------------------------------------------------"

echo" 5. Send the file to my email account"

echo "-----------------------------------------------------------"

echo" 6. Exit"

echo "-----------------------------------------------------------"

// CODE OF PROGRAM TO OPERATING SYSTEMS EX#2


read -p "Insert your option" opc

case $opc in


1) read -p "enter file name:" filename

echo -e " "


echo -e " "

read -p "enter directory to search:" dr

echo -e " "


find $dr -name $fl


;;

2) mkdir ./repository

echo -e "respository directory created "

;;

3) read -p "enter ip address or hostname to connect:" ip

ftp $ip
;;

4) read -p "System Restarted" $shutdown -h now

;;

5)read -p "enter email id:" em; mail -s "firstname lastname"$em<<< 'this is body of the mail'

;;

6)exit;;


esac
done

I need to repair it or at least know the errors that it has

Thanks

Explanation / Answer

Hi,

I fixed the code and it is working fine now. There is a problem in line 28 while getting echo5 where (") written immediately after echo5, which is going to error and the same echo6 and also if you want to comment anything the comment line should start with '#' not with // , this will be used in java to comment.

Please find the below code, which is tested.

#!/bin/bash
clear
date
while true
do

clear
date
echo
echo "-----------------------------------------------------------"

echo "1. Enter file name"

echo "-----------------------------------------------------------"

echo "2. Create a directory called "repository""

echo "-----------------------------------------------------------"

echo "3. Make an FTP from the server to your machine"

echo "-----------------------------------------------------------"

echo "4. Make a reboot of your computer"

echo "-----------------------------------------------------------"

echo "5. Send the file to my email account"

echo "-----------------------------------------------------------"

echo "6. Exit"

echo "-----------------------------------------------------------"

#// CODE OF PROGRAM TO OPERATING SYSTEMS EX#2


read -p "Insert your option" opc

case $opc in


1) read -p "enter file name:" filename

read -p "enter directory to search:" dr

echo -e " "
value=`find $dr -name $filename`
echo "File $value"

sleep 5


;;

2) mkdir ./repository

echo -e "respository directory created "
sleep 5
;;

3) read -p "enter ip address or hostname to connect:" ip

ftp $ip
sleep 5
;;

4) read -p "System Restarted" `sudo shutdown -r now`
sleep 5
;;

5)read -p "enter email id:" em; echo "This will be body of email "| mail -s "firstname lastname" $em
sleep 5
;;

6)exit;;


esac
done

Output:

Thu Mar 29 21:09:21 IST 2018

-----------------------------------------------------------
1. Enter file name
-----------------------------------------------------------
2. Create a directory called repository
-----------------------------------------------------------
3. Make an FTP from the server to your machine
-----------------------------------------------------------
4. Make a reboot of your computer
-----------------------------------------------------------
5. Send the file to my email account
-----------------------------------------------------------
6. Exit
-----------------------------------------------------------
Insert your option1
enter file name:file.xml
enter directory to search:Chapter


File Chapter/file.xml


Thu Mar 29 21:10:15 IST 2018

-----------------------------------------------------------
1. Enter file name
-----------------------------------------------------------
2. Create a directory called repository
-----------------------------------------------------------
3. Make an FTP from the server to your machine
-----------------------------------------------------------
4. Make a reboot of your computer
-----------------------------------------------------------
5. Send the file to my email account
-----------------------------------------------------------
6. Exit
-----------------------------------------------------------
Insert your option2
respository directory created

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote