The code below is adapted from a solution to "Use Expect in a Bash script to provide a password to an SSH command", so as to pass arguments to
git push. I'm not getting any exceptions for passing the wrong uname+pwd, and conversely passing the correct ones does not actually push anything. How can this be corrected?
if (( $# == 2 )) then : else echo "expecting 'username pass', got $@" exit 1 fi user="$1" pass="$2" expect - <<EOF spawn git push expect 'User*' send "$user\r" expect 'Pass*' send "$pass\r" EOF
$ [path]/git_push.sh spawn git push Username for 'https://github.com': foo Password for 'https://[email protected]':
Alternatively (no wildcards):
spawn git push expect "Username for 'https://github.com': " send "$user\r" expect "Password for 'https://[email protected]': " send "$pass\r"