zsh-users
 help / color / mirror / code / Atom feed
* Simple way to get parent process name?
@ 1998-09-15 18:47 Ken Lareau
  1998-09-15 20:13 ` Dan Nelson
  0 siblings, 1 reply; 9+ messages in thread
From: Ken Lareau @ 1998-09-15 18:47 UTC (permalink / raw)
  To: zsh-users

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~1998-09-16 17:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-09-15 18:47 Simple way to get parent process name? Ken Lareau
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

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).