pgrep substitute for porting a linux script to AIX 5.x

Hi, I'm trying to get this script to work on an AIX 5.3 box, I couldn't get pgrep for AIX, I also realize that ps works differently on the IBM boxes. Could anybody just give me the specifics of a work around for my problem, I'll adjust the whole script:
#!/bin/bash
# applabs.com
#to do:
# eliminate funny name processes [done for esecadm, inProgressforGenericUser:seems to be limited char returned!!!]
# CommonLogfile [will be done after metatags symantics are set]
# Aggregates calculation and other metrics
# Fine tune captured content [inProgress]
# Eliminate redundant data eg: eliminate pid feild in pid based listings [inProgress]
#echo "===============START==============="
ROOT_UID=0 # only users with $UID 0 have root privilages.
E_NOROOT=67 # Non-root exit error.
BACKUPDATE=$(date +%m.%d.%Y-%H\:%M\:%S)","
FILENAME=$1-${BACKUPDATE}".mem"

#check if root user.
# Run as root:
if [ "$UID" -ne "$ROOT_UID" ]
then
echo "Must be root to run this script"
exit $E_NOTROOT
fi

IsNumeric () {
case "${1}" in
*[!0-9,]*) return 1;; # invalid
*) return 0;; # valid
esac
}

strcmp ()# string == string
{
local _STRING1=$1 _STRING2=$2 _a _b
case $#.$3 in
2.) ;;
3.*:) _a=${3%:} _b=${3#*:}
set -- `python_to_shell_range "$_a" "$_b" ${#_STRING1}`
_STRING1=${_STRING1:$1:$2}
set -- `python_to_shell_range "$_a" "$_b" ${#_STRING2}`
_STRING2=${_STRING2:$1:$2}
;;
*) echo "Usage: strcmp string1 string2 [a:b]"
return 2
;;
esac
[ "$_STRING1" == "$_STRING2" ]
}
#initialize
cd /root/scripts
pid='pid'
pName='pName'
javaname='javaname'
#cd /root/scripts
#echo ""
tokens=''

echo "Collecting data for the python and bash prcessesi"
# get pairs of PID and processNames per line
for procName in python bash; do
R=$(pgrep -l -x $procName)
tokens=$pidlist' '$R
done

echo $tokens

read -r -a tokenArray <<< $tokens

# Seperate PID and pNames in tokens array.
for token in "${tokenArray[@]}"
do
# PID
if IsNumeric "$token"; then
pid=${token}
else
# PROCESS NAME
pName=$(ps --no-header --pid "${pid}" -o comm)
# LIVE DATA COLLECTION [START]
# METATAGS given: pid, pName
# ___CPU___
#echo "Collecting CPU related data for '"${pName}"'."
header_cpu='CPU_usage(%)'
data_cpu=$(ps --no-header --pid ${pid} -o pcpu)
#___MEMORY___
#echo "Collecting MEMORY related data for '"${pName}"'."
header_memory='PhysicalMemory(%)'
# data_memory=$(ps --no-header --pid ${pid} -o pmem=PhysicalMemory\(\%\),sz=CoreImageSize,vsz=VirtualMemory,rss=ResidentSetSize,resident=ResidentPages,size=RequiredSize,share=Shared)
mt_memory_pmem=$(ps --no-header --pid ${pid} -o pmem)
data_memory=${mt_memory_pmem}

  \# TTY output:
  echo "$\{pName\}"
  \# DATA LOGGING CODE [START]
  mainHeader="DateAndTimeOfReading,"$\{header\_cpu\}","$\{header_memory\}
  logData=$\{data\_cpu\}","$\{data_memory\}
  \# Create and inject header into file if it does not exist
  if [ -f $\{pName\}"\_"$\{pid\}"_"$\{1\}".mem" ]
      then
      :

# echo ${pName}"_"${pid}""${1}".mem :File already exists"
else
# echo "FileDoesNotExist: Updating header..."
echo "Memory Statistics for user: "${1} >> ${pName}"_"${pid}"
"${1}".mem"
echo "["$(uname -a)"]" >> ${pName}"_"${pid}""${1}".mem"
echo "${mainHeader}" >> ${pName}"_"${pid}"
"${1}".mem"
fi
# get memInfo
memInfo=${data_cpu}" "${data_memory}" "${data_time}" "${data_command}
# write timestamp with memInfo
echo ${BACKUPDATE}" ""${logData}" >> ${pName}"_"${pid}"_"${1}".mem"
#===============end=logging===============
fi
done
exit 0

I just need to know how to get the pids given a few process names.
Thanks in advance.

I didn't manage to see where do you define $procName or I'm missing something ? Anyways, you can get the PIDs like :

ps -ef | grep process-name | awk '{print $2}'

HTH

:b: hi and thanks for that, it worked perfectly.
I have another question, can I get ps out put with --no-header option, I couldn't find it in the man pages, I'm doing this script for AIX 5.2 and 5.3
Thanks for the help.
Below is the script as its coming along.#!/bin/bash
# author siddharth.mody@gmail.com
#echo "===============START==============="
ROOT_UID=0 # only users with $UID 0 have root privilages.
E_NOROOT=67 # Non-root exit error.
BACKUPDATE=$(date +%m.%d.%Y-%H\:%M\:%S)","
FILENAME=$1-${BACKUPDATE}".csv"

#check if root user.
# Run as root:
if [ "$UID" -ne "$ROOT_UID" ]
then
echo "Must be root to run this script"
exit $E_NOTROOT
fi

IsNumeric () {
case "${1}" in
*[!0-9,]*) return 1;; # invalid
*) return 0;; # valid
esac
}

strcmp ()# string == string
{
local _STRING1=$1 _STRING2=$2 _a _b
case $#.$3 in
2.) ;;
3.*:) _a=${3%:} _b=${3#*:}
set -- `python_to_shell_range "$_a" "$_b" ${#_STRING1}`
_STRING1=${_STRING1:$1:$2}
set -- `python_to_shell_range "$_a" "$_b" ${#_STRING2}`
_STRING2=${_STRING2:$1:$2}
;;
*) echo "Usage: strcmp string1 string2 [a:b]"
return 2
;;
esac
[ "$_STRING1" == "$_STRING2" ]
}
#initialize
cd /scripts
pid='pid'
pName='pName'

tokens=''

# get pairs of PID and processNames per line

# FOR EACH PROCESS TO BE WATCHED
# PROCESS A:

for procName in proc1 proc1
do
R=$(ps -ef | grep $procName | awk '{print $2} {print $8}')
tokens=$tokens' '$R
done

echo $tokens

echo +++++++++++++++++++++++++++++++++++++++++++++

read -r -a tokenArray <<< $tokens

# Seperate PID and pNames in tokens array.
for token in "${tokenArray[@]}"
do
# PID
if IsNumeric "$token"; then
pid=${token}
else
# PROCESS NAME
pName=$(ps --no-header --pid "${pid}" -o comm)
# LIVE DATA COLLECTION [START]
# METATAGS given: pid, pName
# ___CPU___
#echo "Collecting CPU related data for '"${pName}"'."
header_cpu='CPU_usage(%)'
data_cpu=$(ps -p ${pid} -o pcpu)
#___MEMORY___
#echo "Collecting MEMORY related data for '"${pName}"'."
header_memory='PhysicalMemory(%)'
# data_memory=$(ps --no-header --pid ${pid} -o pmem=PhysicalMemory\(\%\),sz=CoreImageSize,vsz=VirtualMemory,rss=ResidentSetSize,resident=ResidentPages,size=RequiredSize,share=Shared)
mt_memory_pmem=$(ps -p ${pid} -o pmem)
data_memory=${mt_memory_pmem}

  \# TTY output:
  echo "$\{pName\}"
  \# DATA LOGGING CODE [START]
  mainHeader="DateAndTimeOfReading,"$\{header\_cpu\}","$\{header_memory\}
  logData=$\{data\_cpu\}","$\{data_memory\}
  \# Create and inject header into file if it does not exist
  if [ -f $\{pName\}"\_"$\{pid\}"_"$\{1\}".csv" ]
  then 
  :

# echo ${pName}"_"${pid}""${1}".csv :File already exists"
else
# echo "FileDoesNotExist: Updating header..."
echo "Memory Statistics for user: "${1} >> ${pName}"_"${pid}"
"${1}".csv"
echo "["$(uname -a)"]" >> ${pName}"_"${pid}""${1}".csv"
echo "${mainHeader}" >> ${pName}"_"${pid}"
"${1}".csv"
fi
# get memInfo
memInfo=${data_cpu}" "${data_memory}" "${data_time}" "${data_command}
# write timestamp with memInfo
echo ${BACKUPDATE}" ""${logData}" >> ${pName}"_"${pid}"_"${1}".csv"
#===============end=logging===============
fi
done
exit 0

HI I got the solution with:
ps -p 2732036 -o pmem=,pcpu=
:o