Re: psql shell return codes - checking if database exists

From: "Milen A(dot) Radev" <milen(at)radev(dot)net>
To: pgsql-admin(at)postgresql(dot)org
Subject: Re: psql shell return codes - checking if database exists
Date: 2008-04-15 12:10:18
Message-ID: fu25vb$oii$1@ger.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Mario Splivalo написа:
> 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?

A workaround: add "--list" option to the command line and grep for the
database you need.

--
Milen A. Radev

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Julius Tuskenis 2008-04-15 12:17:38 Re: postgres 8.1 usermanagement problem
Previous Message Dmitry Shubin 2008-04-15 12:07:44 postgres 8.1 usermanagement problem