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
Although question has already been answered and accepted, it may also happen that permissions on .pgpass file are not properly set. It has to have the world and group access disallowed:
/bin/chmod 0600 ~/.pgpass