I've written a script that display certain parent and child process IDs. Problem i'm having is writting the parent data into an array and displaying it in ascending order.
This is the function i wrote that outputs the parent data. How do i put the data i get from this function into an array and sort it in ascending order ? Thanks
ps -ef -o ppid,pid,user,args | tail +2 |awk '
function getinfo(PROCID, n) {
# print "getinfo: PROCID=" PROCID
# print "ppids: " ppids[1]
if ((PROCID+1) !=1) {
n = split(pidinfo[PROCID],ppids, " "
print ppids[1], ppidinfo[ppids[1]]
getinfo(ppids[1])
}
}
{procs[$1] = procs[$1] " " $2
ppidinfo[$2] = $3 " " $4
pidinfo[$2] = $1
pidinfor[$2] = $3 " " $4
}
END {
print FID,pidinfo[FID],ppidinfo[FID]
getinfo(FID)
} ' FID=${1:-0}
This is the function i wrote that outputs the parent data. How do i put the data i get from this function into an array and sort it in ascending order ? Thanks
ps -ef -o ppid,pid,user,args | tail +2 |awk '
function getinfo(PROCID, n) {
# print "getinfo: PROCID=" PROCID
# print "ppids: " ppids[1]
if ((PROCID+1) !=1) {
n = split(pidinfo[PROCID],ppids, " "
print ppids[1], ppidinfo[ppids[1]]
getinfo(ppids[1])
}
}
{procs[$1] = procs[$1] " " $2
ppidinfo[$2] = $3 " " $4
pidinfo[$2] = $1
pidinfor[$2] = $3 " " $4
}
END {
print FID,pidinfo[FID],ppidinfo[FID]
getinfo(FID)
} ' FID=${1:-0}