title: getting send: spawn id exp6 not open error
body: <p>I know that this issue has many solutions mentioned here, but I am middle of this issue.
  I have created a ruby script <strong>snaps.rb</strong>.</p>
  
  <p>This script for deleting the lvm snapshots. following code causing the problem</p>
  
  <pre><code>`/usr/bin/expect &lt;&lt;delim
  exp_internal 0
  set timeout 20
  spawn echo itsme | sudo -S lvremove #{snap_name}
  expect {Do you really want to remove active logical volume #{name}? [y/n]:}
  send "y\r"
  expect eof 
  delim`
  </code></pre>
  
  <p><em>snap_name</em> is my <em>snapshot name</em> and I am using expect for passing y or n to the command input. and I am using <strong>backtick(``)</strong> for executing the shell command from ruby. 
  but I getting following error.</p>
  
  <pre><code>send: spawn id exp6 not open
      while executing
  ""end "n
  </code></pre>
  
  <p>How can I resolve this error.</p>