linux - bash scripting: search Java STDOUT for a variable -
when run mytest.jar, outputs alot of information in stdout (not in file) , trying read/search file specific string put variable in bash script.
java stdout:
line 1 info............ line 2 info........... .... ... successful (either 'successful' or 'failed')
how search for, in bash, last line in stdout or ('successful' or 'failed') without redirecting stdout file?
thanks in advance
this not way of checking success or failure.
you should instead rewrite mytest.jar
use system.exit(0)
on success , system.exit(1)
(or higher) on error. if program written, this.
you can check success or failure in bash using e.g.
if java -jar mytest.jar echo "the command succeeded :d" else echo "the command failed :(" fi
all unix programs work way, , should make sure mytest.jar
no exception.
Comments
Post a Comment