Don't smoke your cigar yet.

At least on Ubuntu, which is derived from Debian, ps --forest only shows
the tree back as far as the last shell, which comes AFTER the script, so
it doesn't show the script process.

glitz: pstree -h will highlight the limb for my current process, while
displaying ALL the processes on the system....but (according to the doc)
only *IF* I am logged on to a terminal that supports highlighting. I
presume that will NOT work if my process was started by the scheduler,
since there is no terminal at all. And anyway, I could not find a way to
grep for highlighted output, so no way to find my limb of the tree.

Note: I may have several or many processes running under my uid, and I
want to know if THIS one has a script running on it. In Solaris, the
pstree equivalent lets me choose to ONLY display the limb I am on, all
the way back to the highest (lowest?) level process, so a simple check
for a script command anywhere in the output is a yes/no that my session
is being scripted.

For real server work, not home desktops, one may have a requirement to
always keep a log of what was done, hence the requirement to script what
was done.

Adam Thornton wrote:
On Oct 20, 2007, at 7:01 AM, Carey Tyler Schug wrote:


Let me give one example of glitz vs functionality. From within a shell
script, I wanted to trace up my parent task tree in a shell script.
This
was something simple, I wanted to see if there was a scripting task
running to record the session, so I could start one only if none was
already running. In Solaris this was fairly simple. In Linux, a
similar (though different) command, gave a beautiful multicolored
display on a
terminal, but would have been very difficult to parse to see if the
script command was directly in my parent tree.

ps --forest doesn't seem to give me any colors at all, and "ps --
forest | grep script" is probably roughly what you were looking for,
although if you were feeling studly you'd use awk to throw away the
first few fields and then parse the "\_" bits of the tree out.

Did I know about --forest before I wrote this note? No. I just
thought, "I bet there's a ps option to do that", did a "man ps", hit
forward slash, typed "tree", and got what looked like the right
answer. That's procps, which is standard on SuSE, CentOS, and
Debian, anyway.

Adam

--
Carey Tyler Schug

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390

Reply via email to