From: Julio Leyva <jcleyva@hotmail.com>
To: reedstrm@rice.edu
To: pgsql-admin@postgresql.org
Subject: Re: Querying the hostname of the server
Date: Sat, 1 May 2010 15:32:31 +0000
Message-ID: <BLU102-W2529897925D1499BB8B0CEA1F00@phx.gbl> (raw)
In-Reply-To: <20100430141404.GB28614@rice.edu>
References: <y2yfdeb32eb1004300633rf3a40e7g15a1d07b93f132dd@mail.gmail.com>
<20100430141404.GB28614@rice.edu>
I think you can do something like that as a postgresql user
su - postgres
psql -c "\! uname -n"
or actually you can do that inside of any sql statement
psql
\!uname -n
> Date: Fri, 30 Apr 2010 09:14:04 -0500
> From: reedstrm@rice.edu
> To: pgsql-admin@postgresql.org
> Subject: Re: [ADMIN] Querying the hostname of the server
>
> On Fri, Apr 30, 2010 at 03:33:13PM +0200, Péter Kovács wrote:
> > Hi,
> >
> > I have a number of PostgreSQL servers which I often access through ssh
> > tunnel with Pgadmin3. I would like to double check which one I have landed
> > on (if the tunnel is really configured the way I want). Is there a way to
> > query the hostname from the catalogs?
>
> Hmm, that's a bit tricky, since I assume you're using a local db
> connection inside the tunnel, so inet_server_addr() probably returns
> null. If you're talking unix/linux machines, then /etc/hostname _should_
> have the current hostname in it, so:
>
> create temp table foo (t text);
> copy foo from '/etc/hostname';
> select * from foo;
> drop table foo;
>
> Should work.
>
> Ross
> --
> Ross Reedstrom, Ph.D. reedstrm@rice.edu
> Systems Engineer & Admin, Research Scientist phone: 713-348-6166
> The Connexions Project http://cnx.org fax: 713-348-3665
> Rice University MS-375, Houston, TX 77005
> GPG Key fingerprint = F023 82C8 9B0E 2CC6 0D8E F888 D3AE 810E 88F0 BEDE
>
> --
> Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-admin =
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: jcleyva@hotmail.com, reedstrm@rice.edu
Subject: Re: Querying the hostname of the server
In-Reply-To: <BLU102-W2529897925D1499BB8B0CEA1F00@phx.gbl>
References: <y2yfdeb32eb1004300633rf3a40e7g15a1d07b93f132dd@mail.gmail.com> <20100430141404.GB28614@rice.edu> <BLU102-W2529897925D1499BB8B0CEA1F00@phx.gbl>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox