Hall H.

asked • 02/28/21

Linux urgent question please answer ASAP

  1. Your menu will be surrounded by a loop, either the until or while loop, so that when one option is concluded it will go back to the main menu until the user selects an option x to exit. Try  NOT TO USE THE EXIT command to quit the script, use the proper logic of the loop control to exit the program. Also using while : or while true or until true, etc. is not a good loop logic. You have a menu so, the exit should be an option in the menu such as, when option <> q, etc.
  2. Program in one file

  3. Menu example:
  4. email:~> bash menu_script.sh
  5. Command Menu

  6. a. Emailer Program
  7. b. Users Currently Logged On
  8. c. Current Date and Time
  9. d. This months Calendar
  10. e. name of the Working Directory
  11. f. Contents of the Working Directory
  12. g. Find the IP of a Web Address
  13. h. See your Fortune
  14. i. Print a file (on the screen)
  15. j. Exit

  16. Please select a letter:
  17. Here is samples interaction with the emailer portion of the program. There is no need to display the calendar or show a list of available files to attach.
  18. Please select a letter: a (this would go to the option for the emailer program that you created)

  19. Welcome user

  20. Today is: date

  21. This is this months Calendar:

  22. February 2005
  23. Su Mo Tu We Th Fr Sa
  24. 1 2 3 4 5
  25. 6 7 8 9 10 11 12
  26. 13 14 15 16 17 18 19
  27. 20 21 22 23 24 25 26
  28. 27 28

  29. This program will allow you to send a message,
  30. with a file attachment, to any selected user.

  31. Please enter the subject of your message and press <enter>: Test message

  32. Please enter the email address of the recipient and hit <enter>:

  33. Please enter the file to be attached to this message and press <enter>.

  34. please choose a file: testfile
  35. Then it would got back to the main menu

1) Lack of comments on your program

2) Use of meaningful variable names

3) #!/bin/bash should be the first line of our program.

4) Using the option read -n1 varname allows you to tap on “one key to continue”

5) Many commands might produce a full screen of output and you will not be able to see the what was on the top, always | more

6) Use the command clear to clear the screen and have a non-cluttered output. =======================

7) Use the logic of the loop to get out of the loop, using exit 1 or exit 0 still terminates the program but you are forcing the end of the program instead of using the logic of a loop

8) There are many ways to implement the until loop, but you need to make sure to use the proper operator and initialize the variable before it is checked in the until loop. Otherwise the comparison condition may always be true or false. Same not as above, use the logic of the loop to end it.

9) Consider using functions. They will be easier to troubleshoot if your program does not work and it organizes your program

10) Initialize your variables to a value.

11) Test you emailer.

12) Binary logic. Remember that when you do binary logic you are always comparing two items. For instance if a > b then .. you do not use if a > b > c, you need to break it down into if a > b and a > c

1 Expert Answer


Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.


Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.