I need to write a script which will take pid as an argument and give me the command name, the various network connections associated the process, and it will also give that information for up to three ancestor processes, and up to three generations of descendants.
I don't want the answer to this, but I do want some guidance on how best I can set myself on the right course to finishing this.
This is what I have started out with:
#!/bin/bash #get pid from user PID=$1 #echo pid and find a way to describe process to user echo $PID #whatever it is = #whatever the command name is #network portion sudo netstat -p grep $PID #this return information related to the process itself ps -ef f|egrep "(UID|$PID)"
The last line of code will at least return something somewhat valuable to me: I can get some information related to the process, a tree-like hierarchy, ect ect.
I don't posses a lot of technical knowledge so I understand if this code simply looks horrible/unusable for this assignment. If I need to start from scratch and come up with different ideas I will. Any help or guidance would be greatly appreciated.