Question

In: Computer Science

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 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

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 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...
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...
Write a brief shell script that will take in a specific file name, prompt the user...
Write a brief shell script that will take in a specific file name, prompt the user whether they would like to gzip, bzip2, or xz compress the file. Depending on response, the script then ought to compress the provided file with the corresponding method
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...
Write a shell script that will create a new password-type file that contains user information. The...
Write a shell script that will create a new password-type file that contains user information. The file should contain information about the last five users added to the system with each line describing a single user. This information is contained in the last five lines of both the /etc/shadow and the /etc/passwd files. Specifically, you should produce a file where each line for a user contains the following fields: user name, encrypted password, and shell. The fields should be separated...
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 C code to let the main thread create N child threads, where each created...
Write a C code to let the main thread create N child threads, where each created thread will randomly generate an integer between 0 to 10 and put it into a global array variable. After that, the main thread will calculate the sum of all the generated integers. N should be input as a command line argument. Complete the following C code by filling all “???”s in the code sketch. NOTE: when you compile the code, you need to add...
Using MATLAB or Octave, use documenting code to Write a script that prompts the user for...
Using MATLAB or Octave, use documenting code to Write a script that prompts the user for a minimum and maximum real number, then generates and prints a random number in the requested range. The script should then do the same for an integer range. Sample output: Enter a minimum real value: 0.5 Enter a maximum real value: 30 A random number in the range ( 0.5000, 30.0000 ) is 1.7851 Enter a minimum integer value: -10 Enter a maximum integer...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT