Skip site navigation (1) Skip section navigation (2)

Re: run shell command from pl/pgsql

From: "Henshall, Stuart - Design & Print" <SHenshall(at)westcountry-design-print(dot)co(dot)uk>
To: "'jules(dot)alberts(at)arbodienst-limburg(dot)nl'" <jules(dot)alberts(at)arbodienst-limburg(dot)nl>,pgsql-novice(at)postgresql(dot)org
Subject: Re: run shell command from pl/pgsql
Date: 2002-11-18 10:15:45
Message-ID: E382B5D8EDE1D6118DBE0008C759BCD6116AB1@WCPEXCHANGE (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
Jules Alberts wrote:
> Hello all,
> I'm working on a pg database that should be able to run commands on
> certain conditions. E.g. whenever a date is stored in column X of
> table Y, an email should be sent to user Z. Creating a triggered
> function is easy enough but how do I invoke the command? Also, I want
> to use variables in the executed command, something like:
> 	m_address := ''me(at)myself(dot)org'';
> 	m_subject := ''this is a test'';
> 	runcommand(''mail -s '' + m_subject + m_address);
> I guess the answer is very obvious, but I couldn't find it. TIA for
> any help!
> --
> Jules Alberts.
You can't do this from pl/pgsql, or any other truted language, thats what
the trusted part is about - not giving access to the rest of the system. I
believe Peter E wrote something called pl/sh which gives shell access
(search the archives for an address), or if that doesn't fit you're bill do
a little C (PerlU + other untrusted languages can probably do this as well,
but not tried). To make a C function easier, write the trigger function in
plpgsql, and then have a mailer function to accept the necessary arguments
then do a system command.
- Stuart

pgsql-novice by date

Next:From: Frank YipDate: 2002-11-18 16:23:19
Subject: value too long for type character varying(25)
Previous:From: Jules AlbertsDate: 2002-11-18 08:37:19
Subject: run shell command from pl/pgsql

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group