Re: shell scripting

From: Peter Eisentraut <e99re41(at)DoCS(dot)UU(dot)SE>
To: Marc Tardif <intmktg(at)CAM(dot)ORG>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: shell scripting
Date: 2000-04-05 08:47:31
Message-ID: Pine.GSO.4.02A.10004051044310.16709-100000@Uggla.DoCS.UU.SE
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 4 Apr 2000, Marc Tardif wrote:

> Is ther any way to foresee if a database exists or if a user has
> permission to read/write a database from within a shell script?

The best (and as far as I know the only) way to determine whether you have
access to something is to try to access it. Anything else is destined for
failure some place.

Not tested, but it seems that testing like
psql -c "UPDATE foo SET a = 1 WHERE 5=6"
is sufficient and harmless. (I think psql might also return a non-zero
exit status if this fails.)

--
Peter Eisentraut Sernanders väg 10:115
peter_e(at)gmx(dot)net 75262 Uppsala
http://yi.org/peter-e/ Sweden

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Snow 2000-04-05 13:57:39 Problem report (dropping views that are called by other views)
Previous Message Chris Knight 2000-04-05 05:12:52 RE: startup / shutdown scripts for *BSD?