Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

save java output to a kshell variable

 
zb cong
Ranch Hand
Posts: 416
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mahesh Rana
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
appMsg=`java -version`
echo $appMsg
 
zb cong
Ranch Hand
Posts: 416
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your answer, but it still don't works, if change to following, it works

appMsg=$(java -version 2>&1)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic