 |
 |
Wait
|
 |
|
 |
|
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status:
Offline
|
|
I have a unix bash shell script that launches a Java virtual machine process. I want the script to stay running and not exit after it launches the process. As a matter of fact I would also like for the script to exit only when the Java process that it started quits. In other words, I need the script to mirror the lifecycle of its child process.
I tried the "wait" command but either I'm using it wrong or it doesn't apply for in this case.
Any ideas? Examples?
Thanks!

|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: Edmond, OK USA
Status:
Offline
|
|
Originally posted by DaGuy:
I have a unix bash shell script that launches a Java virtual machine process. I want the script to stay running and not exit after it launches the process. As a matter of fact I would also like for the script to exit only when the Java process that it started quits. In other words, I need the script to mirror the lifecycle of its child process.
I tried the "wait" command but either I'm using it wrong or it doesn't apply for in this case.
Any ideas? Examples?
Thanks!
Well, that should be automatic, E.G.:
Code:
#!/bin/sh
java MyClass
echo HI
This script will not print HI to the console until the Java VM exits. If you spin the java command off in a new process (using &  then maybe you could monitor the PID - but if you really need it to execute synchronously then just do it.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status:
Offline
|
|
Originally posted by absmiths:
Well, that should be automatic, E.G.:
Code:
#!/bin/sh
java MyClass
echo HI
This script will not print HI to the console until the Java VM exits. If you spin the java command off in a new process (using & then maybe you could monitor the PID - but if you really need it to execute synchronously then just do it.
Thanks. Let me add some detail. The java process that I'm referring to is Jakarta's Tomcat Web Server. I'm trying not to add anything to their startup scripts and just wrap around them. I though I could do this by using "wait" on my wrapper launch script.
The Tomcat script is asyncronous so I guess I can't sneak my way around this one...

|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Apr 2000
Location: Woodridge, IL
Status:
Offline
|
|
Without personally knowing the details, you could probably just create a while loop that checks to see if the process is still running and sleeps in the middle. When the process dies, so does the script.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status:
Offline
|
|
That's a great idea. I just wanted to see if the "wait" command would've bailed me out.
THANKS!

|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |