title: Expect In Bash Script
body: <p>I am trying to write an autobuild script. Towards the end of the build command the user is prompted for a password, I'd like to automatically senter the password.  What I have at the moment is </p>
  
  <pre><code>#!/bin/bash
  
  ##stored username and password
  userName = [username]
  password = [password]
  
  ##connect to build server
  ssh ${username]@xx.x.xx.xx
  
  ##checkout copy from svn
  svn co [path of code]
  
  ##change directory to build directory
  cd [build directory of checked out code]
  
  ##start build 
  ##expect password
  /usr/bin/expect &lt;&lt; EOF
      expect "Password: "
      spawn make build
      send ${password}
  EOF
  
  exit
  echo "Build Complete"
  </code></pre>
  
  <p>Another way I was shown of doing the expect within a bash script</p>
  
  <pre><code>expect -c \
      "set timeout -1; \
      spawn make build; \
      expect \"password: \"; \
      send -- \[password]\r\"; \
      expect eof"
  </code></pre>
  
  <p>in the second example the [password] is actuallay a string of the password required.</p>
  
  <p>It sticks on when the build command prompts for password.  I have tried a few other examples and spawn seems to not work at all e.g.</p>
  
  <pre><code>#!/usr/bin/expect
  expect "hello"
  spawn echo "hello"
  send "world"
  </code></pre>
  
  <p>that does nothing until I type "hello" </p>
  
  <p>Any help would be much appreciated! </p>