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.