zsh-users
 help / color / mirror / code / Atom feed
From: Ken Lareau <elessar@deepika.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	[thread overview]
Message-ID: <199809151847.OAA03970@mailhost2.squonk.net> (raw)

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


             reply	other threads:[~1998-09-15 18:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-09-15 18:47 Ken Lareau [this message]
1998-09-15 20:13 ` Dan Nelson
1998-09-16 13:09   ` Ken Lareau
1998-09-16 16:08     ` /usr/bin/script annoyance Dan Nelson
1998-09-16 16:31       ` Ken Lareau
1998-09-16 16:41         ` Dan Nelson
1998-09-16 16:53           ` Ken Lareau
1998-09-16 17:13             ` Ken Lareau
1998-09-16 17:40             ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199809151847.OAA03970@mailhost2.squonk.net \
    --to=elessar@deepika.squonk.net \
    --cc=zsh-users@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).