I have created a .pgpass file in my home directory which looks like this
.pgpass
localhost:5432:somedb:someuser:somepass
I am using a shell scr
Check the owner of the .pgpass file. Just lost half an hour to find out I had created my .pgpass file with sudo. The command for my user and location was chown postgres:postgres /var/lib/pgsql/.pgpass.
chown postgres:postgres /var/lib/pgsql/.pgpass