#!/bin/ksh # pidof: reports PID of a given process. # # BSD ps command: ps axc # # Solaris ps command: ps -ef -o pid,tty,s,time,comm # (use fname instead of comm for first # 8 characters of program basename, # or use /usr/ucb/ps axc) PATH=/bin:/usr/bin export PATH # version: prints the current version to stdout. version () { lsedscr='s/RCSfile: // s/.Date: // s/,v . .Revision: / v/ s/\$//g' lrevno='$RCSfile: pidof,v $ $Revision: 1.1 $' lrevdate='$Date: 2004/05/21 22:11:58 $' echo "$lrevno $lrevdate" | sed -e "$lsedscr" } case "$#" in 1) ;; *) echo "usage: $0 procname" >&2; exit 1 ;; esac case "$1" in -v) version; exit 0 ;; *) ;; esac ps -axc | exec nawk -v prog="$1" '{ if ($5 == prog) print $1 }'