[comp.sys.apollo] Programs with their own names

weber_w@apollo.HP.COM (Walt Weber) (12/16/89)

krowitz%richter@UMIX.CC.UMICH.EDU (David Krowitz) writes:
>I've noticed that a number of Apollo supplied programs
>manage to their process names (the ones shown by /com/pst)
>no matter what name you use when you start the program.
>Anyone have any idea how this is accomplished?

Someone has already supplied the key to this one in an
earlier posting, so I'll post the following Aegis shell
script, written by a wizard whose cloak is no longer in use
in the Chelmsford rings.

Note that this is a PRE-sr10 script, which was most useful on
sr9.7 systems when /bin/ps and /com/pst did not co-operate as
closely as they do under Domain/OS.

Apologies for the lines greater than 80 chars.

...walt...

================cut here===========================================
#!/com/sh
eon
SYSTYPE := bsd4.2
export SYSTYPE
abtsev -max

/bin/ps -axN | /com/chpat -o -a -p 'uid = {[~ ]*}?*[0-9]:[0-9][0-9] {[~ ]*}?*' '@1 @2' @
 | while read uid pname do
    args ^uid | /com/chpat '.' ' ' | read hi lo
    args ^pname | /com/chpat '?*/' '' | read pname
    cnt := 1
    oldname := ^pname
    while existf `node_data/proc_dir/^pname do
        if /bin/ps -axN | /com/fpat "%^pname" | read foo then
            pname := "^oldname.^cnt"
            cnt := ^cnt + 1
        else
            dlf -du -f `node_data/proc_dir/^pname
        endif
    enddo
    /com/ctob `node_data/proc_dir/^pname ^hi ^lo
enddo
=================end cut===========================================
Walt Weber               Hewlett Packard NARC @ Apollo Systems Division
-The views expressed herein are personal, and not binding on ANYONE-
   "The power of accurate observation is commonly called cynicism
    by those who have not got it" -George Bernard Shaw