BACKGROUND: when local username is not the same as the git username, git will insist on asking for the password even in the presence of ~/.netrc (one can hit Enter and then netrc is used, but this Enter is required).
QUESTION: I need to do git pull passing the password to git, but I want to see whatever git replies on the stdout (and possibly later redirect). I tried
#!/usr/bin/expect -f
spawn /usr/bin/git $argv
expect Password:
send "secret"
and it appears to work, but I do not see the git output.
I tried simple
puts "$expect_out(buffer)"
and fancy
while (1) {
expect {
eof {break}
-re ".*" {puts "$expect_out(buffer)"}
}
}
and even fancier
while (1) {
expect {
-re "(\[^\n]*\)\n" { send_user $expect_out(buffer) }
eof {break}
}
}
and a little bit simpler
while (1) {
expect {
"\n" { send_user $expect_out(buffer) }
eof {break}
}
}
and neither prints the git output.
PS. ssh is not an option in this specific case, please do not waste your time talking about it.
You need to “hit enter” after typing the password:
send "secret\r"