[ale] Need help from cammand line and scripting gurus

Mazukna, Thomas Thomas.Mazukna at delta.com
Wed Feb 27 10:42:12 EST 2002


the only problem is that 
ps -Afl returns
 8 S tmazukna  1784     1  0  99 20        ?   5564        ? 08:37:03 pts/40
0:03 /bin/../java/bin/../jre/bin/../bin/

ps -ef returns
tmazukna  1784     1  0 08:37:03 pts/40   0:03
/bin/../java/bin/../jre/bin/../bin/sparc/native_threads/java
-Dbeanfactory.cfg=

but it is still about 200-300 chars too short.

is there a way to get a full invocation command for a pid or get a pid on
the process start form the script ?

thanks,
Tomas


-----Original Message-----
From: Greg Sabino Mullane [mailto:greg at turnstep.com]
To: ale at ale.org
Sent: Wednesday, February 27, 2002 9:59 AM
To: ale at ale.org
Subject: Re: [ale] Need help from cammand line and scripting gurus



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


> ps display only 80 chars whic is not enough 

ps has many options, one of which is the handy "long" format. Your system 
may vary, as ps is one of the more non-portable unix functions, but 
something like this should work to get you started:

ps -Afl | grep mystartclass | grep -qv "grep mystartclass" && StartUpJava

where StartUpJava is the program to run if you do not find anything 
in the ps list that has the phrase "mystartclass."

Quick breakdown:

Run the ps command, showing [A]ll processes, using a [f]ull listing, 
and using the [l]ong format so we can see exactly how each running 
process was invoked. Then we pass those results to grep and return only
those 
lines that contain the word "mystartclass." Since we also match ourself 
(there is a process with a CMD of "grep mystartclass") we again pipe the 
results through to grep, removing our own previous grep comamnd [the 'v'
flag] 
and asking for quiet output [the 'q' flag]. If we get a match, then grep 
returns "true" and the shell moves on (because of the '&&' conditional) 
and executes the StartUpJava program. If there are no matches to the final 
grep, the entire commandly silently dies right before the '&&' and 
StartUpJava never runs. :)

HTH
Greg Sabino Mullane  greg at turnstep.com
PGP Key: 0x14964AC8 200202270924

-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html

iD8DBQE8fPPbvJuQZxSWSsgRAiw/AJsHDeg7PxusniUZTuPasRmdXWFhFgCg6KV1
ndo6cizrsPnn2dfSw3lGeNw=
=hSnV
-----END PGP SIGNATURE-----



---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be

sent to listmaster at ale dot org.

---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
sent to listmaster at ale dot org.






More information about the Ale mailing list