From: | Greg Smith <greg(at)2ndquadrant(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Rob Jaeger <yogirob(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Finding the bin path |
Date: | 2009-12-26 22:54:26 |
Message-ID: | 4B369422.7070800@2ndquadrant.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Tom Lane wrote:
> Rob Jaeger <yogirob(at)gmail(dot)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(at)2ndQuadrant(dot)com www.2ndQuadrant.com
From | Date | Subject | |
---|---|---|---|
Next Message | John R Pierce | 2009-12-26 23:00:46 | Re: Finding the bin path |
Previous Message | fernando | 2009-12-26 22:30:30 | dbi-link with Sybase |