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

keepmoving
  • 1,813
  • 8
  • 34
  • 74

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
keepmoving
  • 1,813
  • 8
  • 34
  • 74