Question

In: Computer Science

Exercise. Practice redirection to change the above commands so that: (i) error messages are sent to...

Exercise.

Practice redirection to change the above commands so that:

(i) error messages are sent to /dev/null, but

(ii) we still detect errors and halt execution of the sequence appropriately.

For i, recall from prior labs that standard error stream (stderr) is #2, and you will need redirection to route an error normally to stderr to /dev/null.

Hint: Recall that redirection happens per process executed. So, what do you need to add to each process to make the redirection successful?

Below are 4 commands to rewrite:

#1) ls . && ls -! && ls -al || echo "We Failed"

#2) ls -! && ls . && ls -al || echo “We Failed”

#3) ls . && ls -al && ls -! || echo "We Failed"

#4) ls . && ls -al || echo “We Failed”

Write a new version of each by copying the list below, and add your revisions to the four above commands:

1.

2.

3.

4.

Solutions

Expert Solution

## Hey bud, here are your commands and explaination. Feel free to ask any doubt. Consider giving a thumbs up. ThankYou :)

# The standard error descriptor is 2.

# To pipe any error to /dev/null we use 2>/dev/null

# If there are multiple statements, then 2>/dev/null has to be used for each one of them

# Or better way to do it is listed below.

# Edited Commands ( Normal Way)


ls . 2>/dev/null && ls -! 2>/dev/null && ls -al 2>/dev/null || echo "We Failed"

ls -! 2>/dev/null && ls . 2>/dev/null  && ls -al 2>/dev/null || echo “We Failed”

ls . 2>/dev/null && ls -al 2>/dev/null && ls -! 2>/dev/null || echo "We Failed"

ls . 2>/dev/null && ls -al  2>/dev/null || echo “We Failed”

# Edited Commands (More Efficient Way)


{ ls . && ls -! && ls -al } 2>/dev/null || echo "We Failed"

{ ls -! && ls . && ls -al } 2>/dev/null || echo “We Failed”

{ ls . && ls -al && ls -! } 2>/dev/null || echo "We Failed"

{ ls . && ls -al } 2>/dev/null || echo “We Failed”

Related Solutions

Here, I detail the validation rules that you should implement and the error messages that must...
Here, I detail the validation rules that you should implement and the error messages that must be shown for invalid inputs: For login page: username input is required. If it is empty, show error message of “Please enter your username.” username input should be at least 5 character. If it is less that 5 character, show error message that “Please enter at least 5 characters.” password input is required. If it is empty, show error message of “Please enter your...
See information in Textbook for Exercise 9-63. I need to change one number. Change the expected...
See information in Textbook for Exercise 9-63. I need to change one number. Change the expected production number of direct labor hours to be 88,000 instead of the quantity given for that in the exercise 9-63 Palladium INC. produces a variety of household cleaning products. Palladium's controller has developed standard costs for the following four overhead items:                                      Overhead Item                        total fixed materials                                 variable rate per direct labor hour                                      Maintenance                                    86,000                                                                  .20                                       Power                                                                                                                            .45                                    Indirect labor                                       ...
So i have my chemistry exam next week and this is a question from the practice...
So i have my chemistry exam next week and this is a question from the practice test. I am wondering more of the how/why for this question than just the answer? How do you tell what is soluable and what isn't how to know what the reaction is gonna be? Is there any easier way to think about this than memorizing the solubility chart. And even with he chart memorized... how do i answer a question like this, am i...
CHAPTER 10: See information in Textbook for Exercise 10-50. I need to change two numbers. Change...
CHAPTER 10: See information in Textbook for Exercise 10-50. I need to change two numbers. Change the number of units produced to be 410,000 and the number of pounds of materials purchased to be 2,075,000 instead of the quantities given for these in the exercise. 10-50 At the beginning of the year, Crag Company had the following standard cost sheet for one of its plastic products.                                     Direct materials ( 5 lbs @ 54.00)             $20.00                                      Direct Labor ( 2...
Making change. In Exercise 12, for each i ≥ 0, determine the number of ways ci...
Making change. In Exercise 12, for each i ≥ 0, determine the number of ways ci of obtaining i¢ if you have the given coins. Ways are distinguished solely by how many of each type of coin they contain. 12. 1 dime, 3 nickels, and 5 pennies. (i=17; write formula for generating function, but don’t have to simplify it if you don’t need to)
“I don’t like statistical tests,” Ben says grumpily. “There’s so much chance for error, especially Type...
“I don’t like statistical tests,” Ben says grumpily. “There’s so much chance for error, especially Type I error. I don’t understand why we don’t just set alpha really low, like 0.01 or even zero, and have a much lower chance of error.” What would you say to Ben, in 200 words or less?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT