psql exit code

From: Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>
To: pgsql-general(at)postgresql(dot)org
Subject: psql exit code
Date: 2008-11-10 10:43:08
Message-ID: 20081110114308.766f79d5@dawn.webthatworks.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm running:

ON_ERROR_STOP="on" PGPASSFILE="/somewhere" psql dbname username -f
script.sql
(or alternatively <script.sql)

echo $?
always returns 0 even when sql is clearly wrong.

If I do:
ON_ERROR_STOP="on" PGPASSFILE="/somewhere" psql dbname username -c
"selectz 1 from pippo;"

echo $?
returns 1

psql (PostgreSQL) 8.3.4

How can I know if something went wrong other than parsing the output?

Thanks

--
Ivan Sergio Borgonovo
http://www.webthatworks.it

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2008-11-10 10:56:57 Re: psql exit code
Previous Message Ori Garin 2008-11-10 09:02:44 Postgres dies on standby server after triggering failover