2

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 protected] -p 1234qwer

That why I have no idea how to execute heroku login command in bash script. Has anyone got some advice?

2 Answers 2

11

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I tried on mac. For some reason, it stuck after password is entered. (didn't run enter after expect fill the password)
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.

1 Comment

Unfortunately, this doesn't seem to work anymore. I've also tried interpolating environment variables (api key and email) in ~/.netrc and have had mixed luck with that approach - it works ~50% of the time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.