Received: from maia.hub.org (maia-1.hub.org [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id D2F416325E7 for ; Sat, 1 May 2010 12:32:41 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 18916-05 for ; Sat, 1 May 2010 15:32:33 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from blu0-omc3-s37.blu0.hotmail.com (blu0-omc3-s37.blu0.hotmail.com [65.55.116.112]) by mail.postgresql.org (Postfix) with ESMTP id 19449632292 for ; Sat, 1 May 2010 12:32:33 -0300 (ADT) Received: from BLU102-W25 ([65.55.116.72]) by blu0-omc3-s37.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Sat, 1 May 2010 08:32:32 -0700 Message-ID: Content-Type: multipart/alternative; boundary="_1c9c11df-2871-4f4d-92f0-964df596e3b1_" X-Originating-IP: [99.242.77.60] From: Julio Leyva To: , Subject: Re: Querying the hostname of the server Date: Sat, 1 May 2010 15:32:31 +0000 Importance: Normal In-Reply-To: <20100430141404.GB28614@rice.edu> References: , <20100430141404.GB28614@rice.edu> MIME-Version: 1.0 X-OriginalArrivalTime: 01 May 2010 15:32:32.0927 (UTC) FILETIME=[848B1AF0:01CAE943] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.909 tagged_above=-10 required=5 tests=BAYES_00=-1.9, HTML_MESSAGE=0.001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201005/2 X-Sequence-Number: 34475 --_1c9c11df-2871-4f4d-92f0-964df596e3b1_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I think you can do something like that as a postgresql user su - postgres =20 psql -c "\! uname -n" or actually you can do that inside of any sql statement psql=20 \!uname -n > Date: Fri=2C 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 >=20 > On Fri=2C Apr 30=2C 2010 at 03:33:13PM +0200=2C P=E9ter Kov=E1cs wrote: > > Hi=2C > >=20 > > 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 lan= ded > > on (if the tunnel is really configured the way I want). Is there a way = to > > query the hostname from the catalogs? >=20 > Hmm=2C that's a bit tricky=2C since I assume you're using a local db > connection inside the tunnel=2C so inet_server_addr() probably returns > null. If you're talking unix/linux machines=2C then /etc/hostname _should= _ > have the current hostname in it=2C so: >=20 > create temp table foo (t text)=3B > copy foo from '/etc/hostname'=3B > select * from foo=3B > drop table foo=3B >=20 > Should work. >=20 > Ross > --=20 > Ross Reedstrom=2C Ph.D. reedstrm@rice.edu > Systems Engineer & Admin=2C Research Scientist phone: 713-348-6166 > The Connexions Project http://cnx.org fax: 713-348-3665 > Rice University MS-375=2C Houston=2C TX 77005 > GPG Key fingerprint =3D F023 82C8 9B0E 2CC6 0D8E F888 D3AE 810E 88F0 BED= E >=20 > --=20 > Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-admin = --_1c9c11df-2871-4f4d-92f0-964df596e3b1_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I think you can do something like that as a postgresql user

su - pos= tgres
 =3B
psql -c "\! uname -n"

or actually you can do th= at inside of any sql statement

psql
\!uname -n



>=3B Date: Fri=2C 30 Apr 2010 09:14:04 -0500
>=3B From: reedstrm@r= ice.edu
>=3B To: pgsql-admin@postgresql.org
>=3B Subject: Re: [AD= MIN] Querying the hostname of the server
>=3B
>=3B On Fri=2C Apr= 30=2C 2010 at 03:33:13PM +0200=2C P=E9ter Kov=E1cs wrote:
>=3B >=3B= Hi=2C
>=3B >=3B
>=3B >=3B I have a number of PostgreSQL ser= vers which I often access through ssh
>=3B >=3B tunnel with Pgadmin3= . I would like to double check which one I have landed
>=3B >=3B on = (if the tunnel is really configured the way I want). Is there a way to
&= gt=3B >=3B query the hostname from the catalogs?
>=3B
>=3B Hmm= =2C that's a bit tricky=2C since I assume you're using a local db
>=3B= connection inside the tunnel=2C so inet_server_addr() probably returns
= >=3B null. If you're talking unix/linux machines=2C then /etc/hostname _s= hould_
>=3B have the current hostname in it=2C so:
>=3B
>= =3B create temp table foo (t text)=3B
>=3B copy foo from '/etc/hostnam= e'=3B
>=3B select * from foo=3B
>=3B drop table foo=3B
>=3B =
>=3B Should work.
>=3B
>=3B Ross
>=3B --
>=3B R= oss Reedstrom=2C Ph.D. reedstrm@rice.edu>=3B Systems Engineer &=3B Admin=2C Research Scientist phone: = 713-348-6166
>=3B The Connexions Project http://cnx.org = fax: 713-348-3665
>=3B Rice University MS-375=2C Houston=2C TX 77005=
>=3B GPG Key fingerprint =3D F023 82C8 9B0E 2CC6 0D8E F888 D3AE 810E= 88F0 BEDE
>=3B
>=3B --
>=3B Sent via pgsql-admin mailing = list (pgsql-admin@postgresql.org)
>=3B To make changes to your subscri= ption:
>=3B http://www.postgresql.org/mailpref/pgsql-admin
= = --_1c9c11df-2871-4f4d-92f0-964df596e3b1_--