HP3000-L Archives

September 2001, Week 3

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Mark Bixby <[log in to unmask]>
Reply To:
Mark Bixby <[log in to unmask]>
Date:
Mon, 17 Sep 2001 11:50:40 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (45 lines)
Instead of $WORK_PID, try ENVIRON["WORK_PID"] instead.  Note that you must have
exported WORK_PID with the shell "export" command in order for awk to see it.

There is a section in the awk docs at
http://docs.hp.com/mpeix/pdf/36431-90007.pdf that covers environment
variables.  See also the -v parameter, which gives you another way to make
external data values visible to awk.

- Mark B.

Carl McNamee wrote:
>
> I busy writing a shell script that is supposed to take down a particular
> application and then determine if the application actually quit.  If the
> application is still running then set a variable that will be used later in
> the script.
>
> The line in the script I'm having problems with is:
>   ps -ef|grep cmMain | awk '$2 != $WORK_PID {system("export
> cmmain_flag=2")}'
> When this command runs I receive the error "awk: Field $() is not correct".
> The $WORK_PID is an environment variable that was previously set to the pid
> of the current process.  What I'm trying to do with the awk command is
> filter out the grep command finding itself (which seems to happen fairly
> regularly and completely screws up the rest of the script!).  I tried
> surrounding the $WORK_DIR in quotes (single, double and tilde) but that did
> not fix the problem.
>
> Thoughts?  Comments?  Criticism?
>
> Carl McNamee
> Systems Administrator
> Billing Concepts
> (210) 949-7282
>
> * To join/leave the list, search archives, change list settings, *
> * etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

--
[log in to unmask]
Remainder of .sig suppressed to conserve scarce California electrons...

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2