Currently i'm writing a bash script to cd into a folder and run git pull with the password prompt
Notes: my git server is private so i'm using the following git remote url ssh://username@ip-address/path-to-git-folder so i can't use https with password within the url
I'm trying the following bash script
#!/bin/bash
cd /path-to-repo/repo-folder
echo "mygitpassword" | sudo -S git pull
which doesn't work, i checked and it doesn't pull the changes
i also tried to used expect command prompt like the following:
#!/bin/bash
cd /path-to-repo/repo-folder
/usr/bin/expect <<EOF
spawn git pull
expect -re "^.*password.*$"
send -- "mygitpassword\r"
EOF
echo "Done"
from the debug i can see that the regex matched and it's sending the "mygitpassword" (i can't copy paste the debug because i'm using a streaming machine)
summary of the expect debug output:
...
expect: does 'username@ip password: '(spawn_id exp6) match regular expression "^.*password.*$"? Gate "*password*? gate=yes re=yes
expect: set expect_out(0, string) "username@ip's password: "
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) "username@ip's password: "
send: sending "mygitpassword\r" to { exp6 }
Done
both methods showing it running till the echo "Done" but none are actually inputing the password
Right now i'm out of options with git pull(i can't do ssh git pull because i don't have access to the company git private server)
expect -timeout 60 eofafter sending the password. change the timeout value as needed.