Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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?



pgsql-admin by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group