Skip to content

Instantly share code, notes, and snippets.

@twetzel
Created July 28, 2012 20:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save twetzel/3194695 to your computer and use it in GitHub Desktop.
Save twetzel/3194695 to your computer and use it in GitHub Desktop.
Expect script for Capistrano .. to deploy a private git repo (need sudo-pwd in deploy)
alias gcap='~/git_cap gitname gitpwd'
#!/usr/bin/expect -f
# Expect script to supply username/password to cap deploy to git private repository
# This script needs username and password as arguments to connect to git server:
# ------------------------------------------------------------------------
# ./git_cap gituser gitpwd
# -------------------------------------------------------------------------
# set Variables
set g_user [lrange $argv 0 0]
set g_pwd [lrange $argv 1 1]
set timeout -1
spawn cap deploy
match_max 100000
# Look for user prompt
expect "*?sername:*"
send -- "$g_user\r"
send -- "\r"
# Look for passwod prompt
expect "*?assword:*"
send -- "$g_pwd\r"
send -- "\r"
# Look for user prompt
expect "*?sername:*"
send -- "$g_user\r"
send -- "\r"
# Look for passwod prompt
expect "*?assword:*"
send -- "$g_pwd\r"
send -- "\r"
expect eof
@twetzel
Copy link
Author

twetzel commented Jul 28, 2012

username & password are expected 2 times .. so sudo-pwd can be added as well ( with exp_continue ) .. so every password prompt after the second is interpreted as sudo-pwd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment