Get Pid from a command output

pariosd -status

NodeName ID ROLE STATE PROTECTION
---------------------------------------------------------------------------
tn320_scm10 10 ACTIVE UP No Protection
tn320_scm11 11 UNKNOWN UNKNOWN

LocalApps PID STATE
-----------------------------------------------
HAM 3567641 RUNNING
SCM 3600404 RUNNING
ADF 3600411 RUNNING
EFM 3600412 RUNNING
WSM 3600413 RUNNING
AOP 3600414 RUNNING
INTDRV 3600415 RUNNING
CONFDPROXY 3600416 RUNNING
SYSCALL 3760161 RUNNING
LOGMGR 3760163 RUNNING
NODEMGR 3772452 RUNNING
ALARMMGR 3797029 RUNNING
ISSU 3797031 RUNNING
CHASMGR 3797032 RUNNING
ETHMGR 3797033 RUNNING
AOPMGR 3797034 RUNNING
ADFMGR 3797035 RUNNING
EFMMGR 3797036 RUNNING
OSCMGR 3797037 RUNNING
WSMMGR 3797038 RUNNING
SERVMGR 3829807 RUNNING
GMPLSNNI 3829808 RUNNING

I need to get the pid for each of the process shown above in sh script.
Please help me

Ravi

---------- Post updated at 04:33 PM ---------- Previous update was at 04:28 PM ----------

To be more specific,

After getting the PID of the process, i need to create a core dump for each of the process. how i can go thru a loop for collecting only the pid necessary

Thanks,
Ravi

I'm not familiar with pariosd, but assuming it works like you've shown:

pariosd -status | tail -n +8 | awk '{print $2}'

tail -n +8 prints all lines after the first eight.
awk '{print $2}' prints the second field, the pid.

So you could loop through them like this:

for pid in $(pariosd -status | tail -n +8 | awk '{print $2}'); do
    echo $pid
done
pariosd -status |awk 'NR>8 {print $2}' 

For core dump, You need explain to us which type of PIDs you are interesting. Any rules to identify them?

Hi, we Use QNX dumper process to create the core dump

#dumper -p <pid>

Thanks a lot , you gave me awesome solution.

I have one more question though, I have a file called apps.conf, and i need to parse and store the binary name in an array.
In the following, "execname = /PARIOS/sbin/scm", the executable binary name is scm...and so on.

Can you please give some solution...like how to store only binary names in an array.

# SCM Driver
[SCM]
execname = /PARIOS/sbin/scm
args = none
priority = mid
wait = no
critical = no
redundant = no
lock = no
dependency = none
debug_env = MEM_BAS

# ADF Driver
[ADF]
execname = /PARIOS/sbin/adf
args = none
priority = mid
wait = no
critical = no
redundant = no
lock = no
dependency = SCM
debug_env = MEM_BAS

Try this one:

BINARIES=()
while read LINE; do
    BINARIES[${#BINARIES[@]}]=$LINE
done < <(sed -n '/^execname = /s/^execname = //p' apps.conf)
IFS=$'\n'
BINARIES=($(sed -n '/^execname = /s/^execname = //p' apps.conf))

bash 4.0

readarray -t BINARIES < <(sed -n '/^execname = /s/^execname = //p' apps.conf)
pariosd -status |awk 'NR>8 {print $2}' |xargs dumper -p

---------- Post updated at 03:59 PM ---------- Previous update was at 03:52 PM ----------

$ awk '/^execname/ {print $NF}' apps.conf
/PARIOS/sbin/scm
/PARIOS/sbin/adf

or only the name without full path

$ awk -F \/ '/^execname/ {print $NF}' apps.conf
scm
adf

To assign the O/P to array, you can refer konsolebox's