From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25242 invoked from network); 15 Sep 1998 18:52:10 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 15 Sep 1998 18:52:10 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id OAA16385; Tue, 15 Sep 1998 14:45:44 -0400 (EDT) Resent-Date: Tue, 15 Sep 1998 14:44:35 -0400 (EDT) Message-Id: <199809151847.OAA03970@mailhost2.squonk.net> To: zsh-users@math.gatech.edu Subject: Simple way to get parent process name? Date: Tue, 15 Sep 1998 14:47:40 -0400 From: Ken Lareau Resent-Message-ID: <"1Qp7P2.0.--3.JMh_r"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1802 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu At my current job I compile a lot of various packages, and tend to log my configuration, compilation and installation procedures for future reference, using the 'script' command. To keep myself from getting con- fused as to whether I was in a 'script' process or not, I would have the shell prompt change to something else while running 'script'. In ksh, I'd found no easier way to do this other than: ppid() { /bin/ps -o ppid -p $1 | tail -1; }; pname () { /bin/ps -o comm -p $1 | tail -1; }; for functions to get the PPID and the name, and then testing $(pname $(ppid $$)) to see if it was equal to 'script'. For Solaris 5.4, the two previous functions were even worse: ppid() { /bin/ps -lp $1 | tail -1 | tr -s ' ' | cut -c2- | cut -d' ' -f5; }; pname() { /bin/ps -p $1 | tail -1 | tr -s ' ' | cut -c2- | cut -d' ' -f4; }; So my question is, now that I'm using zsh as my shell at work, is there a simpler way to do this? I know zsh has PPID, but I need the actual process name as well. Any suggestions? Ken Lareau elessar@numenor.org