Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Wait

Wait
Thread Tools
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
May 29, 2003, 02:27 PM
 
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
Reply With Quote
May 29, 2003, 03:03 PM
 
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.
     
DaGuy  (op)
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
May 29, 2003, 03:30 PM
 
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
Reply With Quote
May 29, 2003, 04:37 PM
 
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.
     
DaGuy  (op)
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
May 29, 2003, 06:30 PM
 
That's a great idea. I just wanted to see if the "wait" command would've bailed me out.

THANKS!

     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 06:06 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2