[ale] Need help from cammand line and scripting gurus

Greg Sabino Mullane greg at turnstep.com
Wed Feb 27 09:58:56 EST 2002



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






More information about the Ale mailing list