Question

In: Computer Science

Write shell script code that displays a list of all active processes in the system. Lift...

Write shell script code that displays a list of all active processes in the system. Lift the BSD-style “only yourself” restriction. The output should show the status of the processes.

#!/bin/bash


while [[ $REPLY != x ]]; do
clear

echo -e "Launch utilities:\n 1. Process Tree\n 2. Process States\n 3. Threads\n"

read -p "Enter selection [1-3], or type x to exit: " REPLY

if [ $REPLY == 1 ]; then
   echo -e "\n"

   #identify a command that displays the tree of processes in Linux
#identify the options of the command you have found that meet the requirements described in section "Process Tree" of the description of Homework 03
#put the command here, followed by the options. For example, if the command is called displayprocesstree, and the options are -a, -b, and -c, the command would appear as follows:
# displayprocesstree -abc

read void
   clear
fi

if [ $REPLY == 2 ]; then
#identify the command that displays a list of processes on the system. identify the options of that command that can include the state of each process in the output

   read void
   clear
fi

if [ $REPLY == 3 ]; then
#display a string that asks the user to enter the pid of one of the processes
#read a pid from the user onto a variable
# display the threads created by that process

read void
clear
fi

done

Solutions

Expert Solution

#!/bin/bash


while [[ $REPLY != x ]]; do
clear

echo -e "Launch utilities:\n 1. Process Tree\n 2. Process States\n 3. Threads\n"

read -p "Enter selection [1-3], or type x to exit: " REPLY

if [ $REPLY == 1 ]; then
echo -e "\n"
pstree -psa $$
ps -aef --forest
read void
clear
fi

if [ $REPLY == 2 ]; then
ps u
read void
clear
fi

if [ $REPLY == 3 ]; then
read -p "Enter PID: " p_id
ps -T -p $p_id
read void
clear
fi

done


if you have any doubt then please ask me without any hesitation in the comment section below , if you like my answer then please thumbs up for the answer , before giving thumbs down please discuss the question it may possible that we may understand the question different way and we can edit and change the answers if you argue, thanks :)


Related Solutions

Write shell script code that displays the process tree on a Linux machine. The process tree...
Write shell script code that displays the process tree on a Linux machine. The process tree should show the process identifier of each process. Those processes that have the same ancestor should be sorted by process identifier instead of by name. The process tree should show the full names of all threads, if any and available. Whenever the user identifier associated with a process differs from the user identifier associated with the parent of that process, the process tree should...
Write shell script code that shows all threads created by a given process. The user will...
Write shell script code that shows all threads created by a given process. The user will provide the process identifier of that process. #!/bin/bash while [[ $REPLY != x ]]; do clear echo -e "Launch utilities:\n 1. Process Tree\n 2. Process States\n 3. Threads\n" read -p "Enter selection [1-3], or type x to exit: " REPLY if [ $REPLY == 1 ]; then    echo -e "\n"    #identify a command that displays the tree of processes in Linux #identify...
Write a shell script (to run on the Bourne shell) called cp2.sh to copy all the...
Write a shell script (to run on the Bourne shell) called cp2.sh to copy all the files from two named directories into a new third directory. Timestamps must be preserved while copying files from one directory into another. Task Requirements Three directory names must be supplied as arguments to your script when it is executed by the user. In the beginning of your script you need to check that the first two directory names provided (e.g. dir1 and dir2) exist...
this is bash scripting. a. Write a shell script that adds an extension “.deb” to all...
this is bash scripting. a. Write a shell script that adds an extension “.deb” to all the files in a directory. b. Write a command sequence or a script to insert a line “GHIJKLM” at every 10th line of a file? c. Write a bash command or script to find all the files modified in less than 5 days and print the record count of each.
(10pts) Write a shell script to display your name to the screen. (10pts) Write a shell...
(10pts) Write a shell script to display your name to the screen. (10pts) Write a shell script to take a directory as an argument and display the contents of that directory (10pts) Write a shell script that takes any command as a parameter and displays help on that command (e.g. the result of the execution of man <command>). (10pts) Write a shell script that requires two file names as parameters and copies content of one file into another without asking...
Write a complete shell script that first asks the user to enter a URL. The script...
Write a complete shell script that first asks the user to enter a URL. The script should read the URL into a variable named url. The shell script should then retrieve the file associated with the URL by using the curl command. The output of the curl command should be redirected to a file named html_file. The shell script should then use the grep command to search the file named html_file for the word manhattan. Finally, the shell script should...
1. Write a shell code that prints the integers from 80-90 2. Write a shell code...
1. Write a shell code that prints the integers from 80-90 2. Write a shell code that prints the sum of odd integers that are inputted by the user 3. Write a shell code that reads a set of integers {125, 0, 122, 129, 0, 117} and prints {125, 122, 129, 117} Programming Language: Linux
Simple shell scripting Write a Bash shell script called strcount.sh that counts the number of occurances...
Simple shell scripting Write a Bash shell script called strcount.sh that counts the number of occurances of a given string within a file. The scripts takes two arguments: the name of the file to check and the string to count occurances of. If the file is not found (or not readable), the script should print the error message Cannot access file and exit with code -1. Otherwise, the script should print the number of occurances of the given string and...
List the all seven processes involved in the steady-state active protein concentrations in a cell. Give...
List the all seven processes involved in the steady-state active protein concentrations in a cell. Give a specific example of how the cell controls four of these processes.
Answer question in Python, show all code: Write a program that calculates and displays the end...
Answer question in Python, show all code: Write a program that calculates and displays the end of year balances in a savings account if $1,000 is put in the account at 6% interest for five years. For this problem, assume interest is calculated annually. (That is, if I put $1000 in a bank account at the beginning of the year, then the balance at the end of the year is $1,000 + $1,000*6%.) You may assume no money is removed...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT