title: How to use Expect in a Bash script
body: <p>I am trying to write a script that pulls the latest version of my software from a Git repository and updates the configuration files. When pulling from the repository though, I have to enter a password. I want the script to automate everything, so I need it to automatically fill it in for me. I found this site that explained how to use Expect to look for the password prompt and send the password. I can't get it to work though.</p>
  <p>Here's my script:</p>
  <pre><code>#!/usr/bin/expect -f
  set password [lrange $argv 0 0]
  set timeout -1
  
  clear
  echo &quot;Updating Source...&quot;
  cd sourcedest
  git pull -f origin master
  
  match_max 100000
  # Look for passwod prompt
  expect &quot;*?assword:*&quot;
  # Send password aka $password
  send -- &quot;$password\r&quot;
  # send blank line (\r) to make sure we get back to gui
  send -- &quot;\r&quot;
  expect eof
  
  git checkout -f master
  cp Config/database.php.bak Config/database.php
  cp webroot/index.php.bak webroot/index.php
  cp webroot/js/config.js.bak webroot/js/config.js
  </code></pre>
  <p>What am I doing wrong?</p>
  <p>Here's the site I got it from: <a href="http://bash.cyberciti.biz/security/expect-ssh-login-script/" rel="nofollow noreferrer">http://bash.cyberciti.biz/security/expect-ssh-login-script/</a></p>