[ale] Need help from cammand line and scripting gurus
Greg Sabino Mullane
greg at turnstep.com
Wed Feb 27 13:13:24 EST 2002
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Mea culpa. Made a mistake in my previous post. Should be "||" instead of "&&"
because (presumably) we want to run the command if we do *not* get any
matches. So it should be:
ps -Afl | grep mystartclass | grep -qv \
"grep mystartclass" || StartUpJava
Some random thoughts:
The problem of sun not keeping the entire command-line is more problematic.
The first thing is to check your local 'man ps' to see if it mentions
anything about it. There may be a way to extract it.
This output looks rather strange:
[snip] :00 /bin/../java/bin/../jre/bin/../bin/sparc/native_threads/java
- -Dbeanfactory.cfg=
What's with all the double dot obfuscation? Isn't it simply
/java/jre/sparc/native_threads/java?
Can you have that program cd to the above directory and then call
the java executable? That alone may solve the problem, as the
output would then be:
[snip] :00 java -Dbeanfactory.cfg=
Another suggestion: start the program in a simple shell wrapper with a
unique name:
cat > MyJavaProgram
#!/bin/sh
/java/jre/sparc/native_threads/java -Dbeanfactory.cfg=
chmod 700 MyJavaProgram
You could then grep for "MyJavaProgram" and either trust that info
alone, or match the PID and PPID to find the actual java program.
Finally, if you have control of the starting process, a better way would be to
have it store its own PID somewhere, such as the somewhat standard
/var/run directory as something like "/var/run/myJavaApp.pid" Try to
have the java program create the file when invoked and remove it when it
dies. Your script would then look something like this:
test -f /var/run/myJavaApp.pid && \
ps -Af | egrep -q "^tmazukna +`cat /var/run/myJavaApp.pid` " \
|| StartUpJava
One of those four ways above should work. Hopefully. :)
Greg Sabino Mullane greg at turnstep.com
PGP Key: 0x14964AC8 200202271310
-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html
iD8DBQE8fSGVvJuQZxSWSsgRAv/7AKC3zMn7aiN7i82VckLTeZgXb9gccgCfcspw
8219DvIc8jaQKwqXHYK+KhU=
=Rx5g
-----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