Re: Finding the bin path - Mailing list pgsql-general

From Greg Smith
Subject Re: Finding the bin path
Date
Msg-id 4B369422.7070800@2ndquadrant.com
Whole thread Raw
In response to Re: Finding the bin path  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Finding the bin path  (John R Pierce <pierce@hogranch.com>)
Re: Finding the bin path  (Rob Jaeger <yogirob@gmail.com>)
List pgsql-general
Tom Lane wrote:
Rob Jaeger <yogirob@gmail.com> writes: 
Is there a command or reliable method of finding the location of the
PostgreSQL bin path?   
pg_config --bindir

Although I think not all packagers install this in the base package,
which might limit its usefulness. 
I'm not sure which question Rob meant to ask here:

1) Where can I find the PostgreSQL in my PATH right now?  The best I think you can do here is to try the above pg_config bit first, then if it doesn't work try guess based on "which postmaster".

2) Given a running server, what PostgreSQL binary was used to start it?  You can get some info about a running server using this query (which just suggests what SHOW can give you):

  select name,setting from pg_settings where category='File Locations';

But there's no binary location listed there.  You can dig it out of ps using something like this:

  ps -C postgres -o cmd 2>&1 | grep "/postgres" | cut -d" " -f1
  (Tested on Linux)

You'll need to test on all the UNIX-ish OSes you want to support though, getting ps calls to work perfectly everywhere is harder than it should be.

Only the pg_config technique will be easy to use from Windows I think, but at least there you shouldn't have as many concerns about what subsets of the package are installed--I don't think it's sliced up nearly as fine as you can make the RPM or deb installs for example, such that you can easily have a server running but not pg_config.  I could be wrong about that though.

-- 
Greg Smith    2ndQuadrant   Baltimore, MD
PostgreSQL Training, Services and Support
greg@2ndQuadrant.com  www.2ndQuadrant.com

pgsql-general by date:

Previous
From: fernando@lozano.eti.br
Date:
Subject: dbi-link with Sybase
Next
From: John R Pierce
Date:
Subject: Re: Finding the bin path