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?
git_push.sh
if (( $# == 2 ))then :else echo "expecting 'username pass', got $@" exit 1fiuser="$1"pass="$2"expect - <<EOF spawn git push expect 'User*' send "$user\r" expect 'Pass*' send "$pass\r"EOF
Terminal:
$ [path]/git_push.shspawn git pushUsername for 'https://github.com': fooPassword for 'https://foo@github.com':
Alternatively (no wildcards):
spawn git push expect "Username for 'https://github.com': " send "$user\r" expect "Password for 'https://$user@github.com': " send "$pass\r"