Re: [SQL] a script that queries database periodically

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Bernie Huang <bernie(dot)huang(at)ec(dot)gc(dot)ca>
Cc: PGSQL-GENERAL <pgsql-general(at)postgresql(dot)org>
Subject: Re: [SQL] a script that queries database periodically
Date: 2000-11-27 22:24:55
Message-ID: Pine.LNX.4.21.0011272323020.832-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

Bernie Huang writes:

> My boss wants me to write a script that will send a email report to him
> monthly with the result of database queries.

> I guess a shell script is necessary. So, is it possible to call
> 'psql' and returning its query result and I can use sendmail to email
> the result? Any other idea?

Conceptually, what you want is something like this:

#! /bin/sh

(
echo "Here's your report:"
psql -c 'SELECT ...'
) | mail -s Subject foo(at)bar

Reading man pages on each of these is advisable.

--
Peter Eisentraut peter_e(at)gmx(dot)net http://yi.org/peter-e/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Callis, Adam 2000-11-27 22:27:25 I got Pl/Perl working on Solaris!
Previous Message Partyka Robert 2000-11-27 22:24:46 one ask

Browse pgsql-sql by date

  From Date Subject
Next Message Jason 2000-11-27 22:36:40 Re: [PHP-DB] Re: [SQL] a script that queries database periodically
Previous Message Roberto Mello 2000-11-27 21:56:59 Re: [SQL] a script that queries database periodically