How do I start a batch file and check it's status?
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Michel_Rusconi
Posted On:   Wednesday, December 8, 2004 05:40 AM

First of all I want to say I am a beginner in Java. I am working on an server side application that starts batch files (for database filling). After it starts the batch (.bat) file it has to check the status and write it in the database. The problem I run into the combination of starting the batch and checking the status. So far I have found out that I can run the batch file with starting up an process with the Runtime.getRuntime().exec command. What I haven't found out if it is posible to check the status of this proces in any way. I also found out that with using thread commands like isAlive I can check the status of a thread, but not of an process. And I understand that a thread can't s   More>>

First of all I want to say I am a beginner in Java.



I am working on an server side application that starts batch files (for database filling). After it starts the batch (.bat) file it has to check the status and write it in the database.



The problem I run into the combination of starting the batch and checking the status.



So far I have found out that I can run the batch file with starting up an process with the Runtime.getRuntime().exec command. What I haven't found out if it is posible to check the status of this proces in any way.



I also found out that with using thread commands like isAlive I can check the status of a thread, but not of an process. And I understand that a thread can't start an batch file.




So could anyone please help me on my way. Am I doing something wrong? Is any of the above info incorrect? Or am I on the right way? And if I am on the right way what is the next step?

Thanx in advance.

   <<Less

Re: How do I start a batch file and check it's status?

Posted By:   Christopher_Koenigsberg  
Posted On:   Saturday, December 11, 2004 09:07 AM

Write your "batch files" so that they periodically report on their status, by logging to a file or database etc. And then your monitoring can read the log file. That way you can know more than just if the batch process is alive or not.

Re: How do I start a batch file and check it's status?

Posted By:   WarnerJan_Veldhuis  
Posted On:   Friday, December 10, 2004 06:22 AM

Play around with this snippet:


Process proc = Runtime.getRuntime().exec("myBatchFile.bat");
int waitStatus = proc.waitFor();
int exitValue = proc.exitValue();

About | Sitemap | Contact