Re: Redirecting output from a SELECT command

From: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Redirecting output from a SELECT command
Date: 2010-11-16 08:01:50
Message-ID: ibtdpe$dl9$1@reversiblemaps.ath.cx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On 2010-11-11, peter(at)vfemail(dot)net <peter(at)vfemail(dot)net> wrote:
>
> Frmail email(at)domain(dot)comom a shell prompt in FreeBSD, I can use a command like:
>
> cat file.txt | mail email(at)domain(dot)com
>
> to e-mail the contents of a file somewhere.
>
> Is it possible from a PostgreSQL pgsql> shell prompt to e-mail the results of a:
>
> select * from table;
>
> command somewhere?

yes.

-- open a pipe
\o | mail email(at)domain(dot)com -s 'the database result'
-- run the query
select * from table;
-- close the pipe and cause delivery
\o

> I'd like to share a printed copy of that output with someone, and there's no printer connected to the database server, and I only have access to the database server from the console.

\o | lpr -H SERVER -P QUEUE

(eg into a ssh tunnel leading to printer or server on your lan)

--
⚂⚃ 100% natural

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Thom Brown 2010-11-16 09:33:32 Re: Postgresql certifications
Previous Message Machiel Richards 2010-11-16 07:06:00 Postgresql certifications