Re: How to retrieve the output of an external program?

From: Michael Wood <esiotrot(at)gmail(dot)com>
To: "Jean-Yves F(dot) Barbier" <12ukwn(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: How to retrieve the output of an external program?
Date: 2012-01-08 20:40:04
Message-ID: CAP6d-HWiuH22=5YSshBS5rHUYH5CJ8MDQhR4q4Cd55p2WS2x0A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On 8 January 2012 19:29, Jean-Yves F. Barbier <12ukwn(at)gmail(dot)com> wrote:
> Hi list & happy easter,

It's a bit too early for that, isn't it? Perhaps you meant Valentine's Day? :)

> What I'd like to be able to do is:
> * Run a function that sends parms to an external pgm [no PB],
> * Capture the external pgm output that normally goes to stdout.
>
> Is it possible directly or am I obliged to use a temporary file
> and retrieve it from my function?

I'm not sure, since I've never tried something like this in Postgres,
but perhaps pipe(2), dup2(2), and one of exec*(3) will help?

I haven't read through these, but they might help too:
http://stackoverflow.com/questions/3382485/reading-child-process-output-as-soon-as-some-is-available
http://ubuntuforums.org/archive/index.php/t-1627614.html
http://stackoverflow.com/questions/3835905/redirecting-forked-process-output-to-parent-process-in-c
http://www.chemie.fu-berlin.de/chemnet/use/info/libc/libc_10.html

--
Michael Wood <esiotrot(at)gmail(dot)com>

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Jean-Yves F. Barbier 2012-01-08 21:16:12 Re: How to retrieve the output of an external program?
Previous Message Jean-Yves F. Barbier 2012-01-08 17:29:24 How to retrieve the output of an external program?