Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade 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
zbc
zbc
1 Post
ACCEPTED ANSWER

Pinned topic how to save java output to kshell variable

‏2005-12-07T14:59:56Z |
hello
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
    ishields
    3 Posts
    ACCEPTED ANSWER

    Re: how to save java output to kshell variable

    ‏2006-01-18T21:19:02Z  in response to zbc
    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
    enabled: jitc))
    [/code]

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

    Ian Shields