Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 2A4269FB477 for ; Fri, 27 Oct 2006 16:14:39 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 84170-03-3 for ; Fri, 27 Oct 2006 16:14:27 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from exchange.g2switchworks.com (mail.g2switchworks.com [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 942299FB317 for ; Fri, 27 Oct 2006 16:14:27 -0300 (ADT) Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; Fri, 27 Oct 2006 19:14:25 +0000 Received: from state.g2switchworks.com by mail.g2switchworks.com; 27 Oct 2006 14:14:26 -0500 Subject: Re: How to query information schema from shell script From: Scott Marlowe To: Jon Horsman Cc: pgsql-sql@postgresql.org In-Reply-To: <4f4c2a010610270812r65d321cejf00cb374596f2a5f@mail.gmail.com> References: <4f4c2a010610270631q73de201tb98446f64b942a0e@mail.gmail.com> <4f4c2a010610270657we83aa70o471678507d59c6a0@mail.gmail.com> <4f4c2a010610270812r65d321cejf00cb374596f2a5f@mail.gmail.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1161976466.1655.1744.camel@state.g2switchworks.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Fri, 27 Oct 2006 14:14:26 -0500 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.098 tagged_above=0 required=5 tests=AWL, SPF_PASS, UNPARSEABLE_RELAY X-Spam-Level: X-Archive-Number: 200610/224 X-Sequence-Number: 26613 On Fri, 2006-10-27 at 10:12, Jon Horsman wrote: > In my original email i forgot to mentioned i need to know if the > database exists or not from the shell script. If it doesn't exist i > would then create it. Currently i was just creating the db everytime > our db script is run (since it doesn't hurt the db) but this generates > the 'db already exists' log and I now have the requirement that the > users not see that log. ie, don't run createdb if it already exists. > > In looking through the postgres docs i can see how to check if a table > exists but not how a db exists. > > Again, thanks for the help. Oh, and read this: http://www.gnu.org/software/bash/manual/bashref.html It's a good starters manual for bash / shell programming. For more advanced tutorials, look at: www.deadman.org/bash.html www.tldp.org/LDP/abc/html/index.html