IC5Notice: We have upgraded developerWorks Community to the latest version of IBM Connections. For more information, read our upgrade FAQ.
  • 1 reply
  • Latest Post - ‏2006-01-18T21:19:02Z by ishields
1 Post

Pinned topic how to save java output to kshell variable

‏2005-12-07T14:59:56Z |
see my following code, i want to save the output of "java .." to a variable in the kshell:

echo $(java -version) | read appMsg
echo $appMsg
but it don't work, who can give me some suggestions, thanks in advance.
Updated on 2006-01-18T21:19:02Z at 2006-01-18T21:19:02Z by ishields
  • ishields
    3 Posts

    Re: how to save java output to kshell variable

    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
    enabled: jitc))

    Note that the output is provided on stderr, hence the 2>&1.

    Ian Shields