title: How can I pass a shell script variable into an Expect script?
body: <p>I want to pass the $SPACE variable into an Expect script and get the output and again pass into the shell script.</p>
  <pre><code>#!/bin/bash -x
  
      SPACE=$(df -h | awk '{ print $5 }' | grep -v Use |sort -n |tail -1 | cut -d % -f1)
      #set user &quot;root&quot;
      #set ip &quot;192\.168\.53\.197&quot;
      #echo $SPACE
  
      expect&lt;&lt;EOF
  
      spawn ssh &quot;root\@192\.168\.53\.197&quot;
  
      expect &quot;Password:&quot;
  
      send &quot;Karvy123$\r&quot;;
  
      expect &quot;prompt&quot;
  
      send &quot;$SPACE\r&quot;;
  
      expect &quot;prompt&quot;
  
      EOF
  </code></pre>