pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Milen A. Radev <milen@radev.net>
To: pgsql-admin@postgresql.org
Subject: Re: psql shell return codes - checking if database exists
Date: Tue, 15 Apr 2008 15:10:18 +0300
Message-ID: <fu25vb$oii$1@ger.gmane.org> (raw)
In-Reply-To: <48048E3E.2090807@megafon.hr>
References: <48048E3E.2090807@megafon.hr>

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




view thread (3+ messages)  latest in thread

Message-ID: <fu25vb$oii$1@ger.gmane.org>
Permalink:  ../fu25vb$oii$1@ger.gmane.org/
Also on:    postgresql.org/message-id/fu25vb$oii$1@ger.gmane.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: milen@radev.net
  Subject: Re: psql shell return codes - checking if database exists
  In-Reply-To: <fu25vb$oii$1@ger.gmane.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox