Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 215EE9FA491 for ; Sat, 28 Oct 2006 12:18:59 -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 81704-06 for ; Sat, 28 Oct 2006 12:18:56 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.186]) by postgresql.org (Postfix) with ESMTP id 6DC429FA086 for ; Sat, 28 Oct 2006 12:18:56 -0300 (ADT) Received: by nf-out-0910.google.com with SMTP id g2so1446372nfe for ; Sat, 28 Oct 2006 08:18:55 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=UQxuire2SlyyIY573zxyZzsxouQ/Dt3Hg4LinhUUy2dP+TZc/wrNG0keX2LNhcYz7lFEkMXLg2PUKKQLnM5YCNA4gxYDQOTR9N5NXSolG1TCpiPXLOXyX4T3n0fHmr+SiUWFZMnoIWyTbMQEM6ql9UoBOg3evpiRyLTA3LC1/F4= Received: by 10.48.80.20 with SMTP id d20mr1658695nfb; Sat, 28 Oct 2006 08:18:52 -0700 (PDT) Received: by 10.48.215.19 with HTTP; Sat, 28 Oct 2006 08:18:52 -0700 (PDT) Message-ID: <4f4c2a010610280818u76670cf0x2da8ec3efebcd3fc@mail.gmail.com> Date: Sat, 28 Oct 2006 11:18:52 -0400 From: "Jon Horsman" To: "Scott Marlowe" Subject: Re: How to query information schema from shell script Cc: pgsql-sql@postgresql.org In-Reply-To: <1161976466.1655.1744.camel@state.g2switchworks.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <4f4c2a010610270631q73de201tb98446f64b942a0e@mail.gmail.com> <4f4c2a010610270657we83aa70o471678507d59c6a0@mail.gmail.com> <4f4c2a010610270812r65d321cejf00cb374596f2a5f@mail.gmail.com> <1161976466.1655.1744.camel@state.g2switchworks.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.561 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, SPF_PASS X-Spam-Level: X-Archive-Number: 200610/231 X-Sequence-Number: 26620 I ended up going the pg_catalog route, something like (off the top of my head without a linux machine by to test it) output=$(psql -d template1 -t -c "select * from pg_database where datname='testdb'") if [ -z "$output" ]; then psql createdb testdb else echo 'the db already exists' fi I did the exact same thing for the user using pg_user and usename Jon