Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #!/usr/bin/ksh -p
  2.  
  3. process=$1
  4.  
  5. # if $1 is all numbers, then assume it's a PID, and get the parent process.
  6. if [[ $process = +([0-9]) ]]; then
  7. for pid in $( ptree $process | grep '^[0-9]' | awk '{print $1}' ); do
  8. pfiles $pid | egrep "^$pid:|sockname"
  9. done
  10. else
  11. # if $1 is/has letters, then assume it's a process name, and grep accordingly.
  12. for pid in $( ptree | grep $process | grep '^[0-9]' | awk '{print $1}' ); do
  13. pfiles $pid | egrep "^$pid:|sockname"
  14. done
  15. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement