psql shell return codes - checking if database exists

From: Mario Splivalo <mario(dot)splivalo(at)megafon(dot)hr>
To: pgsql-admin(at)postgresql(dot)org
Subject: psql shell return codes - checking if database exists
Date: 2008-04-15 11:15:10
Message-ID: 48048E3E.2090807@megafon.hr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

I need to check, from a bash script, if certain database exists in a
postgres cluster. When I issue:

psql -U someuser somedatabase

psql returns error code 2 regardless of 'no user' or 'no database'
condition. How could I distinguish from the two?

Mario

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Dmitry Shubin 2008-04-15 12:07:44 postgres 8.1 usermanagement problem
Previous Message lfedden 2008-04-15 09:00:26 OID and filesystem issues