{"id":13785,"date":"2021-11-05T07:37:38","date_gmt":"2021-11-05T07:37:38","guid":{"rendered":"https:\/\/assignmenttutors.net\/blog\/linux-project-computer-science-homework-help\/"},"modified":"2021-11-05T07:37:38","modified_gmt":"2021-11-05T07:37:38","slug":"linux-project-computer-science-homework-help","status":"publish","type":"post","link":"https:\/\/assignmenttutors.net\/blog\/linux-project-computer-science-homework-help\/","title":{"rendered":"Linux project | Computer Science homework help"},"content":{"rendered":"<div>\n<p>The Korn Shell is the UNIX shell (command execution program, often called a command interpreter) that was developed by David Korn of Bell Labs as a comprehensive, combined version of other major UNIX shells. Incorporating all the features of the C shell (csh) and the Tab C-shell (tcsh) with the script language features similar to that of the Bourne Shell, the Korn Shell is considered the most efficient shell. Korn, Bourne, and C are the 3 most commonly used UNIX shells. You will be using the Korn Shell (ksh) for this project in which you will be writing shell script files.<\/p>\n<p>\u00a0<\/p>\n<p>1.<span>\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>Begin by executing the following command from a terminal session in your Ubuntu system:<\/p>\n<p><strong>sudo\u00a0 apt-get\u00a0 install\u00a0 ksh<em>\u00a0 &lt;Enter&gt;<\/em><\/strong><\/p>\n<p>You will immediately be asked to enter your password (csci345). This will install the Korn shell into your Ubuntu system on your PC or Mac for use in this project. Simply type <strong>ksh<\/strong> and &lt;Enter&gt; to go into the Korn Shell (your system prompt will change to $ only) and then enter CTRL-D to exit out of it (your default system prompt of [email\u00a0protected]:~$ will re-appear).<\/p>\n<p>As you go through this exercise and start writing shell scripts, you will learn some additional troubleshooting tips to help you navigate through the Korn Shell (ksh).<\/p>\n<p>Keep track of some of these tips (5 of them) and put them into a Word document in a list format with explanations (at least 150 words in current APA format). Make sure that these are different from those mentioned in the textbook.\u00a0 <\/p>\n<p>2.<span>\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>Do some research on what the Korn Shell is about and what it has to offer. Provide some basic information (3\u20135 key points) in a short report (at least 150 words in current APA format) and compile it into the same Word document as above and submit it with this project. Also, provide 5\u20137 positive features of the Korn Shell (ksh) in the same report (at least 150 words in current APA format) in a list. Below are 3 websites that can assist you in this effort. You will need at least 2 external references for this short report (in addition to your textbook):<\/p>\n<p>&#8211; <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/kornshell.com\/\">http:\/\/kornshell.com\/<\/a><br \/>&#8211; <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/www.dartmouth.edu\/~rc\/classes\/ksh\/print_pages.shtml\">http:\/\/www.dartmouth.edu\/~rc\/classes\/ksh\/print_pages.shtml<\/a> <br \/>&#8211; <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/www.bolthole.com\/solaris\/ksh.html\">http:\/\/www.bolthole.com\/solaris\/ksh.html<\/a> <\/p>\n<p>There are many other websites out there that will give you additional help, if needed. Take a look at the ksh shell script below. There are 3 versions of essentially the same program, which is a wrapper to edit a file under SCCS version control. The basic task is to use the sccs command to \u201ccheck out\u201d a file under version control and then automatically edit the file. The script will then be used by users who may not be particularly advanced UNIX users. Hence, the need for a wrapper script. While the basic functionality is the same across all versions, the differences in safety and usability between the first version and the last (4th) version are worth noting. The first one is extremely bad: it would be written by someone who has just picked up a book on shell scripting and has decided, \u201cI\u2019m a programmer now.\u201d<\/p>\n<p>#!\/bin\/ksh<\/p>\n<p>sccs edit $1<\/p>\n<p>if [ &#8220;$EDITOR&#8221; = &#8220;&#8221; ] ; then<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 EDITOR=vi<\/p>\n<p>fi<\/p>\n<p>$EDITOR $1<\/p>\n<p>\u00a0<\/p>\n<p>This version makes somewhat of an attempt to be user-friendly by having a check for an environmental variable EDITOR setting and using it, if available; however, there are no comments, no error checking, and no help for the user at all. The second one is an improvement, showing some consideration to potential users by having safety checks.<\/p>\n<p>#!\/bin\/ksh<\/p>\n<p>\u00a0<\/p>\n<p># Author: Name Here<\/p>\n<p>\u00a0<\/p>\n<p>if [ $# -lt 1 ] ; then<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 print &#8220;This program will check out a file, or files, with sccs&#8221;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 exit 1<\/p>\n<p>fi<\/p>\n<p>\u00a0<\/p>\n<p># set EDITOR var to &#8220;vi&#8221; if not already set<\/p>\n<p>EDITOR=${EDITOR:-vi}<\/p>\n<p>\u00a0<\/p>\n<p>sccs edit [email\u00a0protected]<\/p>\n<p>$EDITOR [email\u00a0protected]<\/p>\n<p>This is a step above the prior version. It accepts multiple files as potential arguments. It is always nice to be flexible about the number of files your scripts can handle. It also has a usage message if the script is called without arguments. Plus, it is always a good idea to put your name in as well. Unfortunately, there is still quite a bit lacking as you can tell by comparing it to the next version. The third one is a good, solid version; it is a positive role model for your scripts.<\/p>\n<p>\u00a0<\/p>\n<p>#!\/bin\/ksh<\/p>\n<p>\u00a0<\/p>\n<p># SCCS editing wrapper, version 0.3<\/p>\n<p>#\u00a0 Author &#8211; Sys Admin<\/p>\n<p>#\u00a0 Usage: see usage() function, below<\/p>\n<p>\u00a0<\/p>\n<p>usage(){<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 print sedit &#8211; a wrapper to edit files under SCCS<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 print &#8220;usage: sedit file {file2 &#8230;}&#8221;<\/p>\n<p>}<\/p>\n<p>\u00a0<\/p>\n<p># Set EDITOR var to &#8220;vi&#8221; if not already set to something<\/p>\n<p>EDITOR=${EDITOR:-vi}<\/p>\n<p># Could already be in path, but it doesn\u2019t hurt to add it again.<\/p>\n<p># adjust as needed,\u00a0 if your sccs lives somewhere else<\/p>\n<p>SCCSBIN=\/usr\/ccs\/bin<\/p>\n<p>if [ ! -x $SCCSBIN\/sccs ] ; then<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 print ERROR: sccs not installed on this machine. Cannot continue.<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 usage<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 exit 1<\/p>\n<p>fi<\/p>\n<p>PATH=$SCCSBIN:$PATH<\/p>\n<p>\u00a0<\/p>\n<p>if [ $# -lt 1 ] ; then<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 usage<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 print ERROR: no files specified<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 exit 1<\/p>\n<p>fi<\/p>\n<p>\u00a0<\/p>\n<p># Yes, I could use &#8220;sccs edit [email\u00a0protected]&#8221; and check for a single error, but # this approach allows for finer error reporting<\/p>\n<p>for f in [email\u00a0protected] ; do<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 sccs edit $f<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if [ $? -ne 0 ] ; then<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 print ERROR checking out file $f<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if [ &#8220;$filelist&#8221; != &#8220;&#8221; ] ; then<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 print &#8220;Have checked out $filelist&#8221;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 fi<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 exit 1<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 fi<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 filelist=&#8221;$filelist $f&#8221;<\/p>\n<p>done<\/p>\n<p>\u00a0<\/p>\n<p>$EDITOR $filelist<\/p>\n<p>if [ $? -ne 0 ] ; then<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 print ERROR: $EDITOR returned error status<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 exit 1<\/p>\n<p>fi<\/p>\n<p>\u00a0<\/p>\n<p>Here are some nice things to note with this script:<\/p>\n<p><span>\u00b7<span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/span>Sets special variables at the top of the script in a unified place;<\/p>\n<p><span>\u00b7<span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/span>Paranoid checks about EVERYTHING;<\/p>\n<p><span>\u00b7<span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/span>Returns an error status from the script on non-clean exit condition (\u201cexit 1\u201d vs. \u201cexit\u201d); and<\/p>\n<p><span>\u00b7<span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/span>Use of comments. Not only does he\/she specify what he\/she is doing, he\/she clarifies what she\/she is NOT doing and why. <\/p>\n<p><span>3.<span>\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/span>Now that you have the Korn Shell (ksh) installed and have learned more about the language itself, it is time to do some programming:<\/p>\n<p>a.<span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>Write a Korn shell script that accepts exactly 1 command line argument that must be a positive integer. The script will print a comma separated list of integers, all on the same line, starting with the initial command line value and decreasing it by one-to-one. The last printed value must not be followed by a comma. Do not write this script to be executed interactively.<\/p>\n<p><strong>Requirements:<\/strong><\/p>\n<p>\u00a0<\/p>\n<p>The script must be to handle the following error situations:<\/p>\n<p>1.<span>\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>Incorrect number of arguments and<\/p>\n<p>2.<span>\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>Non-positive arguments.<\/p>\n<p>The script file name must be: <strong>printnum.sh<\/strong><\/p>\n<p>The script permissions must be 705 (show in your Word document).<\/p>\n<p>\u00a0<\/p>\n<p><strong>Sample Output (provide yours in same Word document)<\/strong><\/p>\n<p><span>Sunny Day Scenarios:<\/span><\/p>\n<p>\u00a0<\/p>\n<p>[email\u00a0protected]:~$ \u00a0<strong>sh printnum.sh 3<\/strong><\/p>\n<p>3, 2, 1<\/p>\n<p>[email\u00a0protected]:~$<\/p>\n<p>\u00a0<\/p>\n<p>[email\u00a0protected]:~$ \u00a0<strong>sh printnum.sh 10<\/strong><\/p>\n<p>10, 9, 8, 7, 6, 5, 4, 3, 2, 1<\/p>\n<p>[email\u00a0protected]:~$<\/p>\n<p>\u00a0<\/p>\n<p><span>Rainy Day Scenarios: <\/span><\/p>\n<p>\u00a0<\/p>\n<p>[email\u00a0protected]:~$ \u00a0<strong>sh printnum.sh<\/strong><\/p>\n<p>error: program must be executed with 1 argument. usage: printnum.sh value (where value &gt;= 1)<\/p>\n<p>\u00a0<\/p>\n<p>[email\u00a0protected]:~$ \u00a0<strong>sh printnum.sh 2 5<\/strong><\/p>\n<p>error: program must be executed with 1 argument. usage: printnum.sh value (where value &gt;= 1)<\/p>\n<p>\u00a0<\/p>\n<p>[email\u00a0protected]:~$ \u00a0<strong>sh printnum.sh -1<\/strong><\/p>\n<p>error: argument must be a positive number. usage: printnum.sh value (where value &gt;= 1)<\/p>\n<p><strong>Add at least 2 more scenarios in your Word document. <\/strong><\/p>\n<p>b.<span>\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>Write a Korn shell script that will determine which file in a directory has the maximum number of lines (this may be different than the file that has the maximum number of bytes). After determining the file with the maximum number of lines, the script will print out the name of the file and the number of lines. The script must only focus on files and ignore subdirectories. The command <strong>wc<\/strong> may be helpful. Do not write this script to be executed interactively.<\/p>\n<p><strong>Requirements:<\/strong><\/p>\n<p>\u00a0<\/p>\n<p><span>\u00b7<span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/span>The script must allow either no arguments or 1 argument.<\/p>\n<p>1.<span>\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>If zero arguments are specified, the script by default will examine the files in the current directory.<\/p>\n<p>2.<span>\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>If 1 argument is specified, the argument must be the name of a directory. The script will then examine the files in the specified directory.<\/p>\n<p>The script must be able to handle the following error conditions:<\/p>\n<p>1.<span>\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>More than 1 argument is specified.<\/p>\n<p>2.<span>\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>The specified argument is not a directory.<\/p>\n<p>The script file name must be: <strong>maxlines.sh<\/strong><\/p>\n<p>The script permissions should be 705<\/p>\n<p>\u00a0<\/p>\n<p><strong>Sample Output (provide yours in same Word document)<\/strong><\/p>\n<p><span>Sunny Day Scenarios<\/span>(Note: output depends on current directory and may not match the values below):<\/p>\n<p>\u00a0<\/p>\n<p>[email\u00a0protected]:~$ \u00a0<strong>sh maxlines.sh<\/strong><\/p>\n<p>File maxlines.sh has maximum number lines (36 lines).<\/p>\n<p>\u00a0<\/p>\n<p>[email\u00a0protected]:~$ <strong>sh maxlines.sh\u00a0 \/etc<\/strong><\/p>\n<p>File mime.types has the maximum lines with 827 lines.<\/p>\n<p>\u00a0<\/p>\n<p><span>Rainy Day Scenarios:<\/span><\/p>\n<p>\u00a0<\/p>\n<p>[email\u00a0protected]:~$ <strong>sh maxlines.sh junk<\/strong><\/p>\n<p>error: argument must be a directory usage: maxlines.sh [directory]<\/p>\n<p>\u00a0<\/p>\n<p>[email\u00a0protected]:~$ <strong>sh maxlines.sh junk trash<\/strong><\/p>\n<p>error: can only use 0 or 1 arguments. usage: maxlines.sh [directory]<\/p>\n<p><strong>Add at least 2 more scenarios in your Word document.<\/strong><\/p>\n<p>\u00a0<\/p>\n<p>c.<span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>Create a search utility by writing 2 Korn Shell scripts named <strong>srchfile.sh<\/strong> and <strong>srch.sh<\/strong><em>, <\/em>respectively. The script <strong>srchfile.sh<\/strong> will list all occurrences of a string found in a file. The script <strong>srch.sh<\/strong> will list all occurrences of a string in a file or all files in a specified directory. Actually, <strong>srch.sh<\/strong> will use the script <strong>srchfile.sh<\/strong> as if it were just another UNIX command to perform the actual search in a file. In other words, the script <strong>srch.sh<\/strong> needs to be able to use the script <strong>srchfile.sh<\/strong>. Therefore, this assignment recommends that the first script created be the <strong>srchfile.sh<\/strong> script. The script <strong>srch.sh<\/strong> calls the <strong>srchfile.sh<\/strong> script.<\/p>\n<p>\u00a0<\/p>\n<p><strong>Requirements:<\/strong><\/p>\n<p>Part 1<\/p>\n<p>Description.<\/p>\n<p>The shell script <strong>srchfile.sh<\/strong> must accept 2 command line arguments.<\/p>\n<p>1.<span>\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>The script shall first print the name of the file being searched.<\/p>\n<p>2.<span>\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>If there are one more instances of the string in the file, the script shall print each line that contains the matching string, along with the line number of the file. <\/p>\n<p>You may use the UNIX command <strong>grep<\/strong> in your script to do the actual search. In fact, <strong>grep<\/strong> can even print the line number if used with the appropriate option (see man page for <strong>grep<\/strong>).<\/p>\n<p>If the user enters more or fewer than the required number of arguments, the script shall produce an error message and stop.<\/p>\n<p>The first argument shall represent the string to be searched.<\/p>\n<p>The second argument shall represent the name of the file to be searched. If the second argument is not a file, the script shall produce an error message and stop.<\/p>\n<p>The script file name must be: <strong>srchfile.sh<\/strong>.<\/p>\n<p>The script permissions must be 705<\/p>\n<p>\u00a0<\/p>\n<p><strong>Sample Output (provide yours in same Word document)<\/strong><\/p>\n<p><span>In the Sunny Day Scenario<\/span>, the <strong>srchfile.sh<\/strong> script is invoked searching for string root pattern in file passwd in the \/etc directory:<\/p>\n<p>\u00a0<\/p>\n<p>[email\u00a0protected]:~$ \u00a0<strong>sh srchfile.sh root \/etc\/passwd<\/strong><\/p>\n<p>&#8212;&#8212; File = \/etc\/passwd &#8212;&#8212;<\/p>\n<p>1:root:x:0:0:root:\/root:\/bin\/bash<\/p>\n<p>\u00a0<\/p>\n<p><span>In the Rainy Day Scenario<\/span>, script <strong>srchfile.sh<\/strong> is invoked with only 1 command line argument:<\/p>\n<p>\u00a0<\/p>\n<p>[email\u00a0protected]:~$ \u00a0<strong>sh srchfile.sh xxxx<\/strong><\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 error: must provide 2 arguments<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 usage: sh srchfile.sh search-pattern file<\/p>\n<p>\u00a0<\/p>\n<p><span>In the Rainy Day Scenario<\/span>, script <strong>srchfile.sh<\/strong> is invoked with second command line argument \/etc., which is a directory rather than a file:<\/p>\n<p>\u00a0<\/p>\n<p>[email\u00a0protected]:~$ \u00a0<strong>sh srchfile.sh xxxx \/etc<\/strong><\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 error: second argument must be a file<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 usage: .\/srchfile.sh search-pattern file<\/p>\n<p><strong>Add at least 2 more scenarios in your Word document.<\/strong><\/p>\n<p>\u00a0<\/p>\n<p>Part 2<\/p>\n<p>\u00a0<\/p>\n<p>Description.<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/p>\n<p>Now, write a second Korn Shell script named <strong>srch.sh.<\/strong> The <strong>srch.sh<\/strong> script will call the <strong>srchfile.sh<\/strong> script to perform a specific task and accept 2 command line arguments. The first argument shall be a string (pattern) found in the file being searched. The second command line argument shall be the name of a file or a directory.<\/p>\n<p>\u00a0<\/p>\n<p><strong>Requirements:<\/strong><\/p>\n<p>The second argument represents either the name of the file to be searched or a directory. If a directory is entered, then all files in the directory shall be searched.<\/p>\n<p>\u00a0<\/p>\n<p>The script <strong>srch.sh<\/strong> shall use the script <strong>srchfile.sh<\/strong> to search for the string in a given file. If the second argument is a directory, then <strong>srch.sh<\/strong> will invoke <strong>srchfile.sh<\/strong> repeatedly in a loop.<\/p>\n<p>\u00a0<\/p>\n<p>If the user enters more or fewer than the required number of arguments, the script shall produce an error message and stop.<\/p>\n<p>The script file name must be: <strong>srch.sh<\/strong>.<\/p>\n<p>The script permissions must be 705.<\/p>\n<p>\u00a0<\/p>\n<p><strong>Sample Output (provide yours in same Word document)<\/strong><\/p>\n<p><span>Sunny Day Scenario<\/span>, the <strong>srch.sh<\/strong> script searching for string root in the file \/etc\/passwd:<\/p>\n<p>\u00a0<\/p>\n<p>[email\u00a0protected]:~$\u00a0 <strong>sh srch.sh root \/etc\/passwd<\/strong><br \/>&#8212;&#8212; File = \/etc\/passwd &#8212;&#8212;<\/p>\n<p>1:root:x:0:0:root:\/root:\/bin\/bash<\/p>\n<p><span>Rainy Day Scenario<\/span>, script <strong>srch.sh<\/strong> is invoked with only 1 command line argument:<\/p>\n<p>\u00a0<\/p>\n<p>[email\u00a0protected]:~$\u00a0 <strong>sh srch.sh root <\/strong><\/p>\n<p>error: must provide 2 arguments<\/p>\n<p>usage: sh srch.sh search-pattern file<\/p>\n<p>\u00a0<\/p>\n<p><span>Rainy Day Scenario<\/span>, script <strong>srch.sh<\/strong> is invoked with 3 command line arguments:<\/p>\n<p>\u00a0<\/p>\n<p>[email\u00a0protected]:~$\u00a0 <strong>sh srch.sh root1\u00a0 root2\u00a0 root3<\/strong><br \/>error: must provide 2 arguments<\/p>\n<p>usage: sh srch.sh search-pattern file<\/p>\n<p><strong>Add at least 3 more scenarios in your Word document.<\/strong><\/p>\n<p>d.<span>\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>In this exercise, you are to write a Korn shell script that spawns 5 processes and then kills them.<\/p>\n<p>\u00a0<\/p>\n<p><strong>Requirements.<\/strong><\/p>\n<p>This homework assignment requires the creation of 2 Korn shell scripts; 1 script shall be named <strong>simple_script.sh<\/strong> and the main script will be named <strong>process.sh.<\/strong><\/p>\n<p>The source code for <strong>simple_script.sh<\/strong> is given to you below.<\/p>\n<p><strong>Simple_script.sh script<\/strong><\/p>\n<p>Create a small shell script file called <strong>simple_script.sh<\/strong> with the following contents:<br \/>echo \u201cI am simple_script.sh with process ID $$\u201d sleep 5<\/p>\n<p>The <strong>simple_script.sh<\/strong> script file name must be: <strong>simple_script.sh<\/strong>.<em\/><\/p>\n<p>Try running <strong>simple_script.sh<\/strong> at the command line; it will print out its process ID and then sleep for 5 seconds before terminating. Each time you run the script, it will have a different process ID.<\/p>\n<p>\u00a0<\/p>\n<p><strong>process.sh script<\/strong><\/p>\n<p>Design your script named <strong>process.sh<\/strong> as follows:<br \/>Have your script create 5 instances of <strong>simple_script.sh<\/strong> in the background. Each time the script <strong>process.sh<\/strong> creates an instance of <strong>simple_script.sh<\/strong>, the<\/p>\n<p>shell variable $! in <strong>process.sh<\/strong> will contain the process ID of the latest<\/p>\n<p><strong>simple_script.sh<\/strong> script.<\/p>\n<p>After your <strong>process.sh<\/strong> script has created 5 instances of <strong>simple_script.sh<\/strong>, let your <strong>process.sh<\/strong> script sleep for 1 second and then let your <strong>process.sh<\/strong> script start killing the processes using the process ID obtained from $! (see man page for <strong>kill <\/strong>command).<\/p>\n<p>Your script must only start killing processes AFTER it has created ALL 5 instances of <strong>simple_script.sh<\/strong> (i.e., DO NOT create <strong>simple_script.sh<\/strong> process 1. Kill it and then create process 2, kill it and so on).<\/p>\n<p>You MUST use a shell array for the <strong>process.sh<\/strong> script. Use the shell array to store the process IDs of the <strong>simple_script.sh<\/strong> processes.<\/p>\n<p>The script file name must be: <strong>process.sh<\/strong><\/p>\n<p>The script permissions must be 705.<\/p>\n<p>\u00a0<\/p>\n<p><strong>Sample Output (provide yours in same Word document)<\/strong><\/p>\n<p><span>Sunny Day Scenarios (add here) \u2026<em><br \/><\/em>Rainy Day Scenarios (add here) \u2026<\/span> <\/p>\n<p>Below is a sample of the output messages from <strong>process.sh<\/strong> (NOTICE the order of how the scripts are created and destroyed in the same order):<\/p>\n<p>\u00a0<\/p>\n<p>[email\u00a0protected]:~$\u00a0 <strong>sh<\/strong> <strong>process.sh<\/strong><\/p>\n<p>I am simple_script.sh with process ID 12301<\/p>\n<p>I am simple_script.sh with process ID 12302<\/p>\n<p>I am simple_script.sh with process ID 12305<\/p>\n<p>I am simple_script.sh with process ID 12307<\/p>\n<p>I am simple_script.sh with process ID 12309<\/p>\n<p>process is killing process 12301<\/p>\n<p>process is killing process 12302<\/p>\n<p>process is killing process 12305<\/p>\n<p>process is killing process 12307<\/p>\n<p>process is killing process 12309<\/p>\n<p>\u00a0<\/p>\n<p><strong>Add at least 2 scenarios in your Word document.<\/strong><\/p>\n<p><span>\u00b7<span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/span>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p><span>\u00b7<span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/span>Submit a zip file with all Korn Shell script files for step 3, parts a\u2013d, and submit your Word document for steps 1\u20133 (scenarios).<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The Korn Shell is the UNIX shell (command execution program, often called a command interpreter) that was developed by David Korn of Bell Labs as a comprehensive, combined version of other major UNIX shells. Incorporating all the features of the C shell (csh) and the Tab C-shell (tcsh) with the script language features similar to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[],"class_list":["post-13785","post","type-post","status-publish","format-standard","hentry","category-homework-help"],"_links":{"self":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts\/13785","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/comments?post=13785"}],"version-history":[{"count":0,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts\/13785\/revisions"}],"wp:attachment":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/media?parent=13785"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/categories?post=13785"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/tags?post=13785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}