Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- #Description: Dado un PID vĂ¡lido muestra la lista de PIDs desde el dado hasta el PID 0
- #
- #Author:jMa
- #
- if [ \( $# -eq 1 \) ] && [ \( `ps aux | tr -s " " | cut -d " " -f 2 | grep $1 | wc -c` -gt 0 \) ]
- then
- pid=$1
- echo -n "PID $1-->"
- if [ "$1" -eq "0" ]
- then
- echo
- fi
- while [ "$pid" != "0" ]
- do
- ppid=`ps -l $pid | tr -s " " | cut -d " " -f5 | tail -1`
- if [ "$ppid" != "0" ]
- then
- echo -n "$ppid-->"
- else
- echo "$ppid"
- fi
- pid=$ppid
- done
- else
- echo -e "Error\nSintax: ./psacestros PIDExistente"
- fi
Advertisement
Add Comment
Please, Sign In to add comment