title: whiptail: How to redirect output to environment variable?
body: <p>I'm trying to use <a href="http://vmlinux.org/cgi-bin/dwww?type=runman&amp;location=whiptail/1" rel="nofollow noreferrer">whiptail</a> as it's a lightweight alternative to <a href="http://vmlinux.org/cgi-bin/dwww?type=runman&amp;location=dialog/1" rel="nofollow noreferrer">dialog</a> and seems to be installed by default in most systems (i.e., people don't have to go around and install it if it's "forgotten" or wasn't installed by default).
  I checked <a href="https://stackoverflow.com/questions/1562666">question #1562666</a> for a few examples here, but I'm looking for an alternative for redirecting output so that is sets an environment variable, instead of just writing to disk. </p>
  
  <p>For example, when I try with dialog, this works (I see the dialog box, and an environment variable is set):</p>
  
  <pre><code>result=$(dialog --output-fd 1 --inputbox "Enter some text" 10 30)
  echo Result=$result
  </code></pre>
  
  <p>However, this doesn't work when using whiptail in place of dialog, as the dialog box never shows up. I have to redirect it to a disk file and read it, for example:</p>
  
  <pre><code>result=$(tempfile) ; chmod go-rw $result
  whiptail --inputbox "Enter some text" 10 30 2&gt;$result
  echo Result=$(cat $result)
  rm $result
  </code></pre>
  
  <p>It works, and I can use the same tempfile from beginning to end (removing it when the script ends). But it feels awkward to be forced to use the disk just for this, instead of keeping it all in memory (redirecting to an environment variable).</p>
  
  <p>So I'm asking: Am I forgetting something -- or do I <em>really</em> have to use the disk when using whiptail?</p>
  
  <p>Thank you in advance for your feedback.</p>