もしも、使うときは、自己責任でお願いします。
やっぱ、Solarisがラクチンだわ。
-- ptree.sh --
--------------------------------------------------------------------
#!/bin/sh
#
# if you want to use this script, pls remember
# to use it at your own risk.
# ver 1.1
#
TMPDAT=/tmp/ptreedat.$$
TMPDAT2=/tmp/ptreedat2.$$
CREATOR=FALSE
FRT=FALSE
if [ $# -eq 0 ]; then
UNIX95=1 ps -efH
exit 0
elif [ $# -eq 1 ]; then
TGP=$1
elif [ $# -eq 2 ]; then
case "$2" in
-t) FRT=TRUE
;;
*) echo "Usage: ptree.sh [-t]"
exit 1
;;
esac
else
echo "Usage: ptree.sh [-t]"
exit 1
fi
if [ ! -f $TMPDAT ]; then
CREATOR=TRUE
UNIX95=1 ps -efH> $TMPDAT
fi
grep $1 $TMPDAT > $TMPDAT2
while read LINE
do
MYPID=$(echo $LINE | awk 'BEGIN {getline; print $2}')
MYPPID=$(echo $LINE | awk 'BEGIN {getline; print $3}')
if [ "$MYPPID" = "1" ]; then
FRT=TRUE
fi
if [ "$MYPID" = "$1" ] && [ "$FRT" = "TRUE" ]; then
echo $LINE
elif [ "$MYPID" = "$1" ]; then
$0 $MYPPID
break
elif [ "$MYPPID" = "$1" ] && [ "$FRT" = "TRUE" ]; then
$0 $MYPID -t
fi
done < $TMPDAT2
rm $TMPDAT2
if [ "$CREATOR" = "TRUE" ]; then
rm $TMPDAT
fi
exit 0
--------------------------------------------------------------------