Skip to content

Instantly share code, notes, and snippets.

@adamjstewart
Last active July 30, 2016 13:26
Show Gist options
  • Save adamjstewart/930c637515c9040b593f140da3e8dcfc to your computer and use it in GitHub Desktop.
Save adamjstewart/930c637515c9040b593f140da3e8dcfc to your computer and use it in GitHub Desktop.
Automate login to multiple CVS repositories
#!/usr/bin/env expect
# Automates CVS login to ocr, hwr, and rcr.
# Prompts user for password a single time.
# Turn off timeout
set timeout -1
# Ask user for password
stty -echo; # make sure password isn't echo'ed
send "Please input your CVS login password: "
expect -re "(.*)\n"
send "\n"
# Set username and password
set username $env(USER)
set password $expect_out(1,string)
# First logout of all three
foreach directory [list ocr hwr rcr] {
spawn -noecho cvs -d ":pserver:$username@cvs:/export/cvs/$directory" logout
expect eof
}
# Now login to all three
foreach directory [list ocr hwr rcr] {
spawn -noecho cvs -d ":pserver:$username@cvs:/export/cvs/$directory" login
expect "CVS password: "
send "$password\r"
expect eof
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment