Write short shell scripts according to the following specifications. Submit a listing and document what you...
Fantastic news! We've Found the answer you've been seeking!
Question:
![image](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/02/65c397fcba7e2_24465c397fc96ffa.jpg)
Transcribed Image Text:
Write short shell scripts according to the following specifications. Submit a listing and document what you tested and the results. The scripts are all very short and show be submitted in your report, not in separate files. Even if your script doesn't work properly you can get partial marks for describing both the problem and what you would have tested! 1. Write a script containing 4 if statements that reports using separate tests whether or not you can read, write or execute a file, and whether or not you are the owner. The basic algorithm is (repeated 4x) if test the file property then report success report failure else fi Automated Testing: Write a 2nd script that executes the 1" on 4 files: a file in /usr/bin, a plain text file, the shell script itself and a file that you create in the 2nd script where you've turn off read privilege for yourself. Note - this 2nd script can be written before completing the 1st one. (4 marks/2 each) 2. Write a script that prompts the user for a time zone. Test whether or not the timezone file exists in the /usr/share/zoneinfo directory. If it does set the current timezone. Test with a top level time zone, a time zone in a subdirectory and a time zone that does not exist. Then prompt the user for a locale in /usr/share/locale and do the same. Display the date. Report on the status of your tests but you do not have to show the results. (2 marks) 3. Use the pseudo shell variable $RANDOM to generate a random number between 1 and 100 and display it so you can verify that this works! Use read to prompt the user for a guess. If they guess high tell them it's too high. If they guess low tell them it's too low. If it's a match tell them they're right. Test for all 3 conditions to make sure your code works. (2) 4. Write a script that prompts the user for a colour name and then checks if that name is available in the file /usr/share/X11/rgb.txt as a whole word using egrep. Count the number of lines returned using wc. (3 marks) a. If nothing matches at all, report no matches. b. if there is one match output the line and report that the match is approved. C. If there is more than one line that matches, display all the matching lines. (It's OK to use egrep more than once) Write short shell scripts according to the following specifications. Submit a listing and document what you tested and the results. The scripts are all very short and show be submitted in your report, not in separate files. Even if your script doesn't work properly you can get partial marks for describing both the problem and what you would have tested! 1. Write a script containing 4 if statements that reports using separate tests whether or not you can read, write or execute a file, and whether or not you are the owner. The basic algorithm is (repeated 4x) if test the file property then report success report failure else fi Automated Testing: Write a 2nd script that executes the 1" on 4 files: a file in /usr/bin, a plain text file, the shell script itself and a file that you create in the 2nd script where you've turn off read privilege for yourself. Note - this 2nd script can be written before completing the 1st one. (4 marks/2 each) 2. Write a script that prompts the user for a time zone. Test whether or not the timezone file exists in the /usr/share/zoneinfo directory. If it does set the current timezone. Test with a top level time zone, a time zone in a subdirectory and a time zone that does not exist. Then prompt the user for a locale in /usr/share/locale and do the same. Display the date. Report on the status of your tests but you do not have to show the results. (2 marks) 3. Use the pseudo shell variable $RANDOM to generate a random number between 1 and 100 and display it so you can verify that this works! Use read to prompt the user for a guess. If they guess high tell them it's too high. If they guess low tell them it's too low. If it's a match tell them they're right. Test for all 3 conditions to make sure your code works. (2) 4. Write a script that prompts the user for a colour name and then checks if that name is available in the file /usr/share/X11/rgb.txt as a whole word using egrep. Count the number of lines returned using wc. (3 marks) a. If nothing matches at all, report no matches. b. if there is one match output the line and report that the match is approved. C. If there is more than one line that matches, display all the matching lines. (It's OK to use egrep more than once)
Expert Answer:
Answer rating: 100% (QA)
Here is a script containing 4 if statements that reports using separate tests whether or not you can read write or execute a file and whether or not y... View the full answer
Related Book For
Posted Date:
Students also viewed these computer network questions
-
A botanist wishes to estimate the typical number of seeds for a certain fruit. She samples 70 specimens and counts the number of seeds in each. Use her sample results (mean = 38.9, standard deviation...
-
re Regular Languages and Finite Automata (a) Let L be the set of all strings over the alphabet {a, b} that end in a and do not contain the substring bb. Describe a deterministic finite automaton...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
In determining an employee's net pay, which of the following taxes would be deducted? a. FUTA taxes b. SUTA taxes c. FICA taxes d. All of these choices are correct.
-
Consider the function f 1x2 = x2 - 4x + 3 in Exercises. a. What are the inputs if the output is 15? b. Given an output of 8, find the corresponding inputs. c. What is the output if the input is -9?
-
Income distribution. Interpret the results of Problem 62 with both a graph and a description of the graph.
-
Identify the reconciliations which a company must include in its financial statements when it adopts IFRS for the first time.
-
Flaherty Accounting Services pays $2,000 per month for a tax software license. In addition, variable charges incurred average $9 for every tax return the firm prepares. a. Determine the total cost...
-
class, we conside optimizing an Square Error (MSE) loss. practice, there are other choices of loss functions as well. For this problem, we will consider linear regression using Mean Absolute Error...
-
Compte, Incorporated (a U.S.-based company), establishes a subsidiary in Croatia on January 1, 2023. The following account balances for the year ending December 31, 2024, are stated in kuna (K), the...
-
During 2022, The Blue Company sold inventory costing it $1,200,000 to its 100% owned subsidiary, Yellow Company. Blue Company marked up the inventory so that it achieved a 70% gross profits on sales....
-
How can ERP systems help in optimizing supply chain network design and distribution strategies?
-
How can conflicts be managed effectively in a workplace to maintain a productive and harmonious environment?
-
How do stakeholders, sponsors, and management exert influence on a project?
-
Company A produces and sells a popular tablet computer for $400. The tablet carries a warranty such that if the tablet fails within 1.5 years, the company replaces it with a new tablet for free. The...
-
_______________ is the beginning and end of all the innovations Domino's is undertaking. a. The customer experience b. Making the best quality pizza c. Getting the best margin
-
Presto Hospitality??Research Questions 1. a. List the research questions that Presto would need to evaluate to determine whether its concession agreement is a lease. b. Next, list the research qu...
-
Select the correct answer for each of the following questions. 1. On December 31, 20X3, Saxe Corporation was merged into Poe Corporation. In the business combination, Poe issued 200,000 shares of its...
-
Your company is hoping to fill a key technical position and has advertised in hopes of obtaining qualified applicants. Because of the demanding qualifications, the pool of qualified people is limited...
-
Consider the percent change in revenues for the five largest soap and cosmetics firms as shown in Table 8.6.3. View this list as a (very small!) population with just N = 5 units. Consider drawing...
-
Consider the prediction of annual salary from age alone (as compared to exercise 1, where experience was also used as an X variable). a. Find the regression equation to predict annual salary from...
-
Due to unforeseen circumstances, you have to take out a student loan for your senior year. Which one of the following loans should you choose? a. A loan with a nominal 10 percent interest rate with...
-
Find the value at time 50 of the set of end-of-year cash flows shown, if the appropriate rate of return is 11 percent per year: a. $179,255 b. $1,255,000 c. $33,079,044 d. $6,106,191,094 Year(s) 1...
-
Sharon Livingston Manufacturing Company uses the following budgets: Balance Sheet, Capital Expenditure, Cash, Direct Labor, Direct Materials, Income Statement, Manufacturing Overhead, Production,...
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App