3 USAGE
="usage: $0 <pid> [-h, -a] [-f, -e] [-s <regexp>]"
6 if [[ ! "$1" =~ ^
-?
[0-9]+$
]]; then
9 elif [[ ! -d /proc
/$1 ]]; then
10 echo "invalid pid '$1'"; exit 1
13 echo -e "pid '${1}' refers to a running process.\n"
15 while getopts ":s:hafe" opts
; do
18 cat /proc
/"$1"/status
| grep "$OPTARG"
21 echo "$USAGE"; DROPBOOL
=1
24 echo "written by ian sutton."; if [[ $DROPBOOL ]]; then exit 0; fi
30 if [[ ! `readlink /proc/$1/exe` ]]; then
31 echo "no permissions to read pid '$1's executable path"; exit 1
34 echo -n "executable path of pid '$1': "
35 readlink
/proc
/"$1"/exe
38 echo "bad option \"-$OPTARG\""; exit 1
48 #if [[ "$1" -eq "-h" ]]; then
49 # echo "$USAGE"; exit 0
52 #elif [[ "$1" =~ ^-?[0-9]+$ ]]; then
53 # if `ps $1 > /dev/null 2>&1`; then
54 # echo "you win!"; exit 0
57 # echo -ne "invalid pid\n$USAGE"; exit 1
61 #elif [[ "$1" -eq "-e" && "$2" =~ ^-?[0-9]+$ ]]; then
62 # if `ps $2 > /dev/null 2>&1`; then
63 # echo "you win!"; exit 0;
66 # echo -ne "invalid pid\n$USAGE"; exit 1
68 # -s <pid> <regex> case
69 #elif [[ "$1" -eq "-s" && "$2" =~ ^-?[0-9]+$ ]]; then
70 # if `ps $2 > /dev/null 2>&1`; then
71 # echo "you win!"; exit 0;
74 # echo -ne "invalid pid\n$USAGE"; exit 1
77 # echo "$USAGE"; exit 1