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:
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
-
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.
-
A rocket is sitting on the launch pad. The engines ignite, and the rocket begins to rise straight upward, picking up speed as it goes. At about 1000 m above the ground the engines shut down, but the...
-
Consider a 5-year balloon loan for \($250,000.\) The bank requires a monthly payment equal to \($1,450,\) and the interest rate is 6%. How much will the borrower owe when the balloon payment is due?
-
A fellow scientist heard that a Van de Graaff generator built 70 years ago could collect \(5.0 \mathrm{C}\) of charge on its dome, which had a radius of \(1.1 \mathrm{~m}\), and has challenged you to...
-
Speedy Delivery Systems can buy a piece of equipment that is anticipated to provide an 11 percent return and can be financed at 6 percent with debt. Later in the year, the firm turns down an...
-
Who were some of the principal Portuguese explorers? What did they achieve and what were the ramifications of these voyages for Portugal, and the world?
-
Alice has invented a new card game to play with Bob. Alice made a deck of cards with random values between 1 and 52. Bob picks 5 cards. Then, he has to rearrange the cards so that by utilizing the...
-
One of the barriers to listening identified is "information overload." How could this be a product of modern, mediated communication and specifically of technological channels like social media?...
-
The following two-step binomial tree depicts the yearly price path of an underlying share. The length of each time step is one year and the risk free rate is 7% pa continuously compounded. Eastpac...
-
What happened to Mammal diversity during the years immediately following theCretaceous-Paleogene extinction event ?
-
On January 1, 2022 the Red Corp. leased an equipment with the following information: Fixed annual payments at the end of each year Lease term Useful life of equipment Residual value at the end of the...
-
On January 1, Bartholomew Corp., which reports its financial results in accordance with IFRS, issued $10,000,000 of 20-year bonds. The bonds pay a coupon of 5% and were issued when the market rate...
-
This Java code can throw a FileNotFoundException. How could you handle this so that the program continues to execute if the exception is thrown? public void printFileContents (String pathToFile) {...
-
y2, determine xy 3.2 If V arccosec(xy) and %3D simplify. (6) /14/
-
Catherine (aged 42) and Johnson (aged 45) have been married for 12 years. Johnson is a project manager of an event company at a monthly salary of $55,000 with an additional one-month salary of...
-
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...
-
Today's world is data driven with businesses having a deluge of available information available for decision making. Data needs to be given the appropriate place in a companys strategy, but decision...
-
Discuss whether an asset needs to be legally owned to be recorded as an asset on the statement of financial position.
-
Discuss why the cash received from providing a service is revenue, yet the cash contributed by the owner is not revenue.
Study smarter with the SolutionInn App