Question:
Using C Shell Script, write programs to:?
ALI N
2011-11-28 10:41:11 UTC
1) Prompt user to input regular pay, bonus pay and print out total pay (regular + bonus).

2) Loop requesting user input of a single word of data to a maximum of ten times or when user enters “n”. Then display the data entered.

3) (a) prompt the user to enter the letter "l", "p" , "w" or "q"
(b) depending on the input from (a), do the following
(use a C shell case construct ):

l Execute the ls command
p Execute the pwd command
w Execute the whoami command
q Quit the program

If an input other than "l", "p", “w" or “q” is provided,
display the message: "Sorry, that is not a valid option"

(c) The script should continue looping, asking for and processing the input, until the
user enters "q" to quit the program.

4) Perform the following:

- Clear the screen
- Declare an array to hold 10 numbers
- Prompt the user for a number between 1 and 100 (or ENTER to terminate), display an error message if the number is no in this range and reprompt for a number
- Store the number in the array
- Loop repeating steps 3 and 4, include logic so the loop is repeated a maximum of 10 times, terminate the loop if the user just hits return
- Display the following calculations (with labels describing the output):
The sum of all the numbers The average of all the numbers The number of numbers entered The largest number entered The smallest number entered
Three answers:
potatocouch
2011-11-29 09:00:03 UTC
this looks like homework. how far did you get? here's a hand with the case portion



echo "Enter l p w q"

read user_input

case in $user_input

___l)

______ls

______;;

___p)

______pwd

______;;

___w)

______whoami

______;;

___q)

______exit 0

______;;

___*)

______echo "Sorry, that is not a valid option"

______;;



underscores are spaces for readability

put that in a while loop
?
2016-05-16 02:11:56 UTC
Replace the if line with this: if [[ $f =~ - ]] It does a regular expression and forces the true/false answer needed for the if statement.
?
2011-11-28 10:48:06 UTC
?



You don't write shell scripts in C - you write them in commands available within a particular shell, hence "bash scripts" or whatever.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...