2

I'm calling a batch that calls another "jar" that send messages to a server and write a report in the end, the time of execution varies from day to day, and the size of the input used in the batch influences to.

I would like to monitor when the batch auto-closes so I can make my original jar to read the log...

I'm calling it like this

    Process prog = Runtime.getRuntime().exec("cmd /c start C:\\chamados\\corretorRota\\VerificarNumero.bat");

and the batch:

cd C:\chamados\corretorRota
java -jar BatchDispatcher.jar brux0043 5873 gcpn-rota.txt > resultado.txt
exit

(FYI brux0043 = server, 5873 = port gcpn-rota = input file writed previously) (the batch keeps open util the end of the called jar)

2
  • 2
    Shouldn't prog.waitFor() work for you here? Commented Jan 6, 2012 at 18:39
  • @Danny write this in an answer to get the rep points. Commented Jan 6, 2012 at 19:00

2 Answers 2

1

You can write a log with the timestamp whenever the batch file was executed.

put this line in your batch file

echo. |time |find "current" >> log

this will then write the timestamp when the batch file was run to the log. Also, there should be a file called log before executing the batch file.

Now your java program can monitor the log and know how many times and when the batch file was executed.

Sign up to request clarification or add additional context in comments.

Comments

1

You should use

prog.waitFor()

to wait for the process to finish execution.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.