"Strong Scripting Skills" - a definition? - sunday

Rob Windsor windsor at warthog.com
Mon Jan 26 14:52:32 PST 2004


On Mon, 26 Jan 2004 08:21:13 PST, verily did "Roy S. Rapoport" write:

> On Sun, Jan 25, 2004 at 05:07:41PM -0800, Robert Hajime Lanning wrote:
>> <quote who="Alvin Oga">
>>> sometimes grep -v grep is needed, sometimes not... i donno why some
>>> greps does it differently

>> Actualy, this is caused by a race condition.

>> ps -axuw | grep foo | grep -v grep | awk '{print $2}' | xargs kill

>> Each seperate command gets fork()ed and exec()ed with the pipes setup
>> between them.

>> Now, the question is, will the "ps -axuw" initialize and read the
>> process table before or after "grep foo" is exec()ed.  If before, then
>> "ps -axuw" will not
>> have "grep foo" in its listing.  If after, then "ps -axuw" will have
>> "grep foo" in its listing.

> I have to admit that maybe my standards are low -- too low -- but my
> definition of "strong scripting skills" can be most easily explained by the
> answer to this question:

> Given a complex task in the command-line environment, do you know how you'd
> automate it?

> I'm not looking for an explanation of the difference between "ef" and
> "waxu" for ps.  If you can say that your 'kill-by-name' command would have
> a ps <that lists all processes> | grep <bonus points for using a regexp to
> avoid partial matching> | awk | kill then you've got almost-strong-enough
> skills, though that's an often-enough used example (and problem) that most
> people have thought about it before.  

I always thought "grep foo | grep -v grep | awk '{print $2}'" script
fragments existed only because the scripter didn't know how to write 
"awk '/foo/ {print $2}'".

To me, "strong scripting skills" has the implication of "knows many
tools that ship with unix/unix-like OSes, fairly well".  So with that,
not only would they need to know a little about awk, but they'd need to
know why ps(1) isn't portable and how to work around it.

Rob++
----------------------------------------
Internet: windsor at warthog.com                             __o
Life: Rob at Carrollton.Texas.USA.Earth                    _`\<,_
                                                       (_)/ (_)
"They couldn't hit an elephant at this distance."
  -- Major General John Sedgwick



More information about the Baylisa mailing list