-   Linux - Newbie (
-   -   saving result of command in variable (

figure20012 07-22-2012 03:27 AM

saving result of command in variable
saving the version of java in a variable

result=`java -version`;
echo $result;

the result of the command java -version is not copied to the result variable.
Can anyone please help me in saving the result java -version into variable result

pan64 07-22-2012 03:31 AM

java prints version info to stderr. If you want to catch it you need to redirect it to stdout (or catch stderr directly).
try: result=`java -version 2>&1`

figure20012 07-22-2012 03:36 AM

thanks a lot pan64 you saved my life..:)

pan64 07-22-2012 03:48 AM

Glad to help you! Just do not forget to "add reputation" - if you want to say thanks....

All times are GMT -5. The time now is 02:04 AM.