0

I am writing one bash shell script to create connection with postgres and execute multiple queries on one connection. For that I wrote following piece of code.

#!/bin/sh

psql postgresql://$USERNAME:$PASSWORD@$HOST:$PORT -c << EOF
CREATE DATABASE $DB_NAME ;
create user $USER with encrypted password '$PASSWORD';
grant all privileges on database $DB_NAME to $USER;

EOF

But its not working and giving me following error. what's wrong with this syntax.

enter image description here

Still Learning
  • 1,505
  • 5
  • 22
  • 56

1 Answers1

0
#!/bin/sh

psql postgresql://$USERNAME:$PASSWORD@$HOST:$PORT << EOF
CREATE DATABASE $DB_NAME ;
create user $USER with encrypted password '$PASSWORD';
grant all privileges on database $DB_NAME to $USER;

EOF
a_horse_with_no_name
  • 497,550
  • 91
  • 775
  • 843
Still Learning
  • 1,505
  • 5
  • 22
  • 56