Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Build a shell script that will call 2 Perl program scripts. In addition to calling the 2 Perl scripts, your shell script will be the
Build a shell script that will call 2 Perl program scripts. In addition to calling the 2 Perl scripts, your shell script will be the main interface presenting a menu of options to the user as well as have a built in function to sort a data file. Your shell script will need to (1) accept a valid filename at the start of execution, which will be a file that will contain data in the form of a list of words, one per line, and at least 50 entries (/usr/share/dict/words).
This filename will be used in your shell for both a (2) shell function to sort the data in the file and write it to another file in that format, as well as a (3) call to a Perl script that will do the same thing using Perl functions. As with the shell script, the Perl script will sort the file, but the shell script is responsible for writing the sorted data to another file. (4) With either the shell or the Perl way to sort the original file, you will need to prompt for a filename to write the sorted data into.
To start your shell, you will be required to (5) ensure that the user started the shell passing in a filename, and if not either prompt for the filename, or exit the shell with a USAGE : statement. Once in the shell you will prompt the user with a (6) menu interface that will allow the user to select sorting of the file using the shell, sorting using the Perl script, another Perl script, or exit.
Your second Perl script will also use the filename gathered at the start of the shell script, but this Perl script will (7) search for a word in that file and return the line number(s) that word is on, or a "not found" message. This Perl script will require you to (8) open the file in the Perl script and prompt the user for the word to search for. You can (9) prompt the user either in the shell or the Perl program for the word you are looking for.
Menu
$ lab3.sh /usr/share/dict/words
Menu
-------
1) Shell sort
2) Perl sort
3) Perl search
4)Exit
Enter selection :
If user does not add a filename at the command line, prompt for a filename, if none given, then exit. You also need to test for the existence and that the file is not of 0 size. If it doesn't exist or is of 0 size, exit with USAGE: "enter a filename that exists..."
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started