简体   繁体   中英

java- how to code a process to intercept the output streams of program running on remote machine/know when remote program has halted/completed

I want to run a java program on a remote machine, and intercept its logs-- also I want to be able to know if the program has completed execution, and also whether it was successful execution or if execution was halted due to an error.

Is there any ready-made java library available for this purpose? Also, I would like to be able to use this program for obtaining logs/execution completion for remote programs in different languages-- like Java/Ruby/Python etc--

If you're only looking to determine when it has completed (and not looking to really capture all the output, as in your other question) you can simply check for the existence of the process id and, when you fail to find the process id, phone home. You really don't need the logs for that.

You should take a look at the Apache Commons Tailer for reading from another process's logs. As for checking if a process completed successfully, that's a little bit trickier. I would wrap the execution of the process in a shell script that writes out the status to a file that the Java program could then check. See here for more info on how to do that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM