title: Shell: store and display result from an async/network command
body: <p>I have a java command:</p>
  
  <pre><code>java -jar app.jar getToken
  </code></pre>
  
  <p>this, on executing, prompts like this:</p>
  
  <pre><code>user:
  pass:
  </code></pre>
  
  <p>After entering the <code>user</code> and <code>pass</code>, the java app contacts the server and returns a result:</p>
  
  <pre><code>token: 32nd3d4
  </code></pre>
  
  <p>I want to store the result in a variable and display it.</p>
  
  <p>How do i do that with shell scripts?</p>
  
  <p>i've tried:</p>
  
  <pre><code>res=$(java -jar app.jar getToken)
  echo $res
  </code></pre>