K
K
Kizzeon2020-07-11 23:55:13
linux
Kizzeon, 2020-07-11 23:55:13

How to connect to Heroku from bash script?

I need to connect to the database inside Heroku in a bash script:
heroku pg:psql postgresql-db --app myApp
And then execute certain queries.

But if I paste this command into a bash script, then only the connection occurs, and until I log out of Heroku, the rest of the bash script will not work.

How can I connect from a bash script to Heroku-postgresql and run multiple commands?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Victor Taran, 2020-07-13
@Kizzeon

heroku pg:psql -c "command" --app "name-app"will go?

K
Karpion, 2020-07-12
@Karpion

Here is an example for an FTP client:

ftp -i -n сервер <<END
user юзер пароль
cd директория
get файл
mget список_файлов
END
In this variant, you can use inside $переменная, ${переменная}, `команда`, $(команда). And the special characters used, if they need to be entered as they are, you need to backslash; well, the backslash itself also needs to be backslashed.
And if you write in the first line ftp -i -n сервер <<\END, then all special characters cease to be special, you don’t need to backslash anything.
And there are more intelligent systems that allow interactive discussion with a running program.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question