Record PID when launching

I would like to record the PID of a process when i lauch it from my script

something like:

#/bin/bash
$abc_pid = /apps/abc/abc.bin -port6700

I know I can run the ps command and grep for abc.bin. The idea is that becase the process runs on several ports and the argument list of .bin is quite large, it would be easier if I could capture the PID at run time.

I've tried $abc_pid = $! but this does not work. Also, I've read that sometimes that can give a forked PID instead of the parent.

Thanks,

By using pgrep and the -f option (fur full line matching)

#!/bin/bash
Process="/apps/abc/abc.bin -port6700"
$Process
# choose between on of both
PID=$(pgrep -f "$Process") # returns PID where command line matches
PID=$(pgrep -P $$ -f "$Process") # same as above but only whos PPID is the current script
echo "PID = $PID"

thanks, that'll work