see my following code, i want to save the output of "java .." to a variable in the kshell:
echo $(java -version) | read appMsg
but it don't work, who can give me some suggestions, thanks in advance.
ishields 2000001P5B3 Posts
Re: how to save java output to kshell variable2006-01-18T21:19:02ZThis is the accepted answer. This is the accepted answer.Try:
code$ appMsg=$(/opt/IBMJava2-142/jre/bin/java -version 2>&1)
$ echo $appMsg
java version "1.4.2" Java(TM) 2 Runtime Environment, Standard Edition (build
1.4.2) Classic VM (build 1.4.2, J2RE 1.4.2 IBM build cxia32142sr1a-20050209 (JIT
Note that the output is provided on stderr, hence the 2>&1.