Write a bash script called minips.sh. This script will look at each numbered dir
ID: 3912815 • Letter: W
Question
Write a bash script called minips.sh. This script will look at each numbered directory in the /proc directory and for each process print the running program's name name, its process id, and its current state. You can find the name and state of a process in /proc//status. You may notice that there are some errors involving processes that disappear too fast to look at their status files. That is fine, just pipe the errors to /dev/null. Use functions to break up the different parts of the script. You will likely need to use file processing tools you learned in earlier labs to extract the needed information.
Explanation / Answer
minips.sh
//to print the running program`s name
ps -p pid -o format
p--> specifies PID
0--> format enables user defined format
Find out a process name using its PID number with the help of user defined format i.e comm= which means command name, same as the process name.
// Getting Process ID
Program starts a shell (process sh), and '$'--> waiting for inputs.
Enter a command "ls" it shows the printout of the names and pid's of the processes.
// Its Current State
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.