Re: Create Action for psql when NOTIFY Recieved

From: John McKown <john(dot)archie(dot)mckown(at)gmail(dot)com>
To: Daniel Verite <daniel(at)manitou-mail(dot)org>
Cc: Jerry Regan <jerry(dot)regan(at)concertoglobalresources(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Create Action for psql when NOTIFY Recieved
Date: 2017-08-29 15:30:45
Message-ID: CAAJSdjgrZje6w3QeWAYjm+1TSJ0NAWVK2v569gnoDHuNA-6=+w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Aug 29, 2017 at 10:21 AM, Daniel Verite <daniel(at)manitou-mail(dot)org>
wrote:

> Jerry Regan wrote:
>
> > I think I could justify the effort to ‘script’ psql. I’m not so sure I
> can
> > justify the effort to write a standalone program.
>
> As a hack around psql, you could have a script that feeds psql
> with "SELECT 1" from time to time and capture only the
> notifications output:
>
> (echo "listen foo;"; while true; do echo "select 1;"; sleep 1; done) | \
> psql | grep notification
>
> When another session issues NOTIFY foo, 'bar'
> that output filtered by the above command is, for example:
>
> Asynchronous notification "foo" with payload "bar" received from
> server process with PID 20033.
>
> which just needs to be piped into another step that runs your custom
> action.
>

​Sounds like a job for "expect".
https://www.tcl.tk/man/expect5.31/expect.1.html​

>
>
> Best regards,
> --
> Daniel Vérité
>

--
Caution! The OP is an hyperpolysyllabicsesquipedalianist and this email may
cause stress to those with hippopotomonstrosesquipedaliophobia.

Maranatha! <><
John McKown

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Luca Looz 2017-08-29 16:28:49 Serializable Isolation and read/write conflict with index and different keys
Previous Message Daniel Verite 2017-08-29 15:21:01 Re: Create Action for psql when NOTIFY Recieved