I’m trying to push my password over to my git push to make a quick way to add, commit and push, but am unable to get the bash prompt to push and enter my password. Does someone know how to do this? I’m sure it mush be simple….
#!/bin/bash
PWD='password'
read MSG
git add .
git commit -m '"$MSG"'
echo "$PWD" | git push |
If you’re using
gitover ssh, you are not able to pipe in a password because the password is read directly from the tty device, and notstdin(in part to discourage doing things like that! ;)). If you really want to automate the password entry, consider usingexpectwhich can control the tty.expectuses TCL, but there are also modules at least for perl and python if you’re more inclined with one of those.IMO, the better solution would be to set up key based auth. it’s both easier and more secure than what you’re attempting. http://www.debian-administration.org/articles/530 has some info on how to set it up.