Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 #!/bin/bash 2 if [ $# != 1 ] 3 then 4 echo Usage: $0 userid 5 exit 1 6 fi 7 count=ps ax -0
1 #!/bin/bash 2 if [ $# != 1 ] 3 then 4 echo "Usage: $0 userid" 5 exit 1 6 fi 7 count=ps ax -0 user | grep - $1' && [[ $count -ne o ]] && echo "$1 has processes 3. You will now modify the script that you created in Question 2 by using an if-then-else statement instead of the command line-list. The if-then-else statement should determine if there is any processed associated with the userid supplied as a parameter. The script should display a message if there were any processes for the userid, or another message if there were no processes for the userid. Name this script Q3.sh Remember to make your script executable Use the following for the condition in your if-then-else statement (be sure that you understand what this is doing): [ $ (ps a -o user | grep -c $1 ) -gt 0 ] Here's a screenshot of the script in use: whiten1@ubuntuGold :-/Assignments/Assignment7$ ./Q3.sh Usage: ./03.sh userid whiten1@ubuntuGold:~/Assignments/Assignment7$ ./Q3.sh root root has processes whiten1@ubuntuGold:-/Assignments/Assignment7$ ./03.sh rootie rootie has no processes whiten1@ubuntuGold:-/Assignments/Assignment7$ 1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started