Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 3E720133655C for ; Tue, 25 Jan 2011 13:06:05 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 89664-07 for ; Tue, 25 Jan 2011 17:05:57 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-iw0-f174.google.com (mail-iw0-f174.google.com [209.85.214.174]) by mail.postgresql.org (Postfix) with ESMTP id 6C9E31337B68 for ; Tue, 25 Jan 2011 13:05:57 -0400 (AST) Received: by iwn9 with SMTP id 9so5306627iwn.19 for ; Tue, 25 Jan 2011 09:05:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:to:cc:subject:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=ncqRvx7v9EljkZYne2bYVxzcmaTX6a+6FP+IeVud+RQ=; b=DsI9PihdzVLWDJek28siuqWQGjXlOnTrwwc9VxzGitF2jo0LGtiBXndi+r9aeHvNd9 WB1B0rle3GUSeu+fHMzpFJFVRYEK9T+sf/6JCTlSclWrC+hvZJOTpGngQWHgDbDho1yx DcwL6ePg00jQO+2NITnLKCONxTCEjWSSKbOq4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:cc:subject:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=hQ8p6mAm8h/dm0pg8K0Q77xYqkfFrTf8f3/DF0WrrQ+ydLoSPbWtnjl2/LKojWyu3M CTkTIbvSF+QUwWosT1nFxHQ0s7pKTcqx7a8bWyEC5gWMh4YUyXhck6omsv2bWGg9SD62 RMmeIr0pTJDA27NegGMUbNSTu8s7ngKmos/YA= Received: by 10.42.178.135 with SMTP id bm7mr6986701icb.101.1295975156076; Tue, 25 Jan 2011 09:05:56 -0800 (PST) Received: from eddie (c-67-186-249-122.hsd1.ut.comcast.net [67.186.249.122]) by mx.google.com with ESMTPS id jv9sm10903150icb.13.2011.01.25.09.05.54 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 25 Jan 2011 09:05:55 -0800 (PST) Message-ID: <4d3f02f3.c9e82a0a.3c9a.6881@mx.google.com> Date: Tue, 25 Jan 2011 10:05:26 -0700 From: Joshua Tolley To: manuel antonio ochoa Cc: pgsql-sql@postgresql.org Subject: Re: control function pgsql with script bash References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="rqzD5py0kzyFAOWN" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7 X-Spam-Level: X-Archive-Number: 201101/86 X-Sequence-Number: 35033 --rqzD5py0kzyFAOWN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jan 25, 2011 at 10:46:58AM -0600, manuel antonio ochoa wrote: > Good morning >=20 > I want to check if the function pgsql execute correctly into my bash > script . > I have something like this : >=20 > /var/lib/pgsql/bin/./psql -U 'USER' -d DATABSE -p 5432 -h iphost -c > "select antros.changethenames( )" >=20 > how can i get the error if the function changethenames() send me one. ? >=20 > thnks See http://www.postgresql.org/docs/9.0/static/app-psql.html#AEN74212 Turn on ON_ERROR_STOP, and psql will give you an exit status of 3 when something goes wrong in your script. I don't know of a way, aside from pars= ing the output, that you can identify exactly where the problem arose. -- Joshua Tolley / eggyknap End Point Corporation http://www.endpoint.com --rqzD5py0kzyFAOWN Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAk0/AtYACgkQRiRfCGf1UMNn8QCeLpT3EK/63t+AA0p2U/yNLPHZ 4MkAoKl+03HTHEcewddKS949tNg44Wjj =RM0I -----END PGP SIGNATURE----- --rqzD5py0kzyFAOWN--