问题
I try to write a script in which I call some command from heroku toolbelt. Script works fine till I am login to heroku toolbelt. When I've tried to add heroku's login command during script execution I occured some problems - there is no in heroku toolbelt command such as (command with parameters):
heroku login -u email@mail.com -p 1234qwer
That why I have no idea how to execute heroku login command in bash script. Has anyone got some advice?
回答1:
For these kinds of things I use expect.
You need to install expect
first. If you're on Ubuntu run sudo apt-get install expect
Then in a script, let's call it heroku_login.exp, enter this with the relevant information:
#!/usr/bin/expect
spawn heroku "login"
expect "Email:"
send "YOUREMAIL";
send "\r"
expect "Password (typing will be hidden):"
send "YOURPASSWORD"
send "\r"
interact
Then run expect heroku_login.exp
and you should be good to go.
回答2:
An easier solution to this problem may be to just set the HEROKU_API_KEY
environment variable. The Heroku toolbelt will then automatically log you in using that key.
来源:https://stackoverflow.com/questions/29311797/log-in-to-heroku-via-bash-script