Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this, it must be done in bash. Please test it before posting the answer thank you! Please include the option 8

I need help with this, it must be done in bash. Please test it before posting the answer thank you! Please include the option 8 because in the other Assignment that I did it didn't work.

image text in transcribedimage text in transcribed

Instructions As was the case in the previous assignment, in this assignment you will develop a menu-based shell script which will run Linux commands. This shell script will to introduce more details in the options including protection against invalid inputs, missing file attachments, etc. Your menu will need to perform these functions (replacing the parentheses with your name and removing # comments): . elcome to (write your name here! main menu 1Display users currently logged in -Display a calendar for a specific month and year #user is asked for a month and year to be displayed Display the current directory path Change directory 5Long listing of visible files in the current directory 6Display current time and date and calendar 7 -- Start the vim editor #user will be asked which file to open, and if the file does not exist, then create new one 8 -- Email a file to a user #use the emailer program crea ted in assignment 6 but add error checking 9Quit ake your selection: Use proper loop structure NOT recursively invoking the script from within the script itself . The selection of an item from the menu should perform the desired action until the user selects"9 Quit" which will return the user to the shell prompt. Avoid using the exit command - use well structured logic instead. Clear the screen (clear) after or before every action so the screen is not cluttered. After the user selects 1-8, the output of that option is displayed and until the user presses a key such as return or space. The command option read -n1 could work nicely in this case. Item 2 look at the cal command and its options. You will ask the user which month and year they would like to see and the chosen calendar would be displayed. HINT: what happens if the user types dates outside of the calendar range? Do not allow them to use something like year 23049934, but rather use if statements to select range as follows: "Please enter a year between 1950 and 2050". If a user enters 1454, for instance, then display an "out of range" message. Although the cal command itself does display an error messages if out of range values are entered, the point of this is to prove that you can do your own error checking. Also, this is to see if you understand the if/ficontrol structure. Item 4 prompt the user for a directory where they would like to go. If the directory exists and is accessible, change to that directory; if no directory is entered change to the home directory. Problem: what happens if the user types or SHOME, will it work? If not, then try to fix that using the eval command or some other mechanism. Item 5- remember that you may have many files in a directory and you will need to stop one page at a time; pipe through less if the output is too long. Item 7- should prompt the user for a file; if the file exists and is a readable ordinary file, edit that file using the vi editor, otherwise create that file. Also, prevent the user from opening binary files in vim. HINT: You can use the command file to find out if the file is ordinary text file combined with the grep command. Item 8 Some of the work on this option is already done in a previous assignment. You should prompt the user for a username, and if the username exists on our syccuxas01 system, it should then prompt for a file name much like item 7 with the protections not allowing users to attach binary files or directories. Also, remember to prompt the user to enter a subject. HINT: use grep to find if the user exists in /etc/passwd file. Remember this command? mail -s "subject" usertosend

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions