Log in to Heroku via bash script

丶灬走出姿态 提交于 2021-02-05 07:15:47

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!