Search Postgresql Archives

Re: Is postgres installed?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 21/05/2010 9:43 PM, christophe.andre@xxxxxxxxxxxxxxxx wrote:
Hi,

How I know whether Postgres is already installed or not on a machine(on
Linux and Windows)?
I found that pg_ctl --version could be used

Only if PostgreSQL's binary directory is on the PATH, which it may not be especially on Windows.

There's no reliable way to detect a PostgreSQL install on UNIX/Linux/BSD either. You can look for pg_ctl on the path and tell the user that the pg_ctl for the postgresql install they want to use simply must be on the path. However, some Linux flavours support parallel installation of multiple versions of PostgreSQL (and multiple clusters for a given version), and will *not* have pg_ctl on the path for versions of PostgreSQL installed on the system.

On Ubuntu/Debian you'll only find `pg_ctlcluster', which is a pg_ctl wrapper that takes additional 'version' and 'cluster' arguments. On these systems you can use pg_lsclusters to find PostgreSQL clusters.

Alternately, you could simply require the user to set up the PATH manually, eg

  PATH=/usr/lib/postgresql/8.4/bin:$PATH  ./yourprogram

which will work anywhere and everywhere there's a Pg install.

or I also tried to check into
the registry (for windows HKLM\SOFTWARE\PostgreSQL\Installations), however
with Windows Server 2003 pg_ctl is not recognized (probably not in the
path) and the registries are not written (nothing appears under
HKLM\SOFTWARE\)

How was Pg installed? Using which installer package?

Here (Vista, XP and Windows 7) Pg appears under
   HKLM\Software\Postgresql\Installations\postgresql-8.4
as installed by the EnterpriseDB "one-click" installer.

If you "installed" Pg from the zip file, there's no real way to figure out if it's installed except checking the PATH for pg_ctl.exe or checking the running process list for postgres.exe . Both are fallible - the former if pg_ctl isn't on the path, the latter if PostgreSQL is installed but not currently running.

--
Craig Ringer

--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux