Re: [m-users.] Capturing process output.
Volker Wysk <[email protected]> Sat, 31 Aug 2024 19:33:44 +0200
| Newsgroups | gmane.comp.lang.mercury.general |
|---|---|
| Message-ID | <[email protected]> |
Am Samstag, dem 31.08.2024 um 18:10 +0100 schrieb emacstheviking: > My use case right now is calling an OS command from my FORTH dialect, but > a while back I wrote some code that binds to libCurl and chucks the > response back into a string, I will probably use that code as well as I > have some words to implement; GET PUT POST DELETE OPTIONS. > > I like your idea for a predicate as proposed but it might be YAGNI across > a wider audience i.e. if it was that much of an in-demand feature I > suspect it would already be available. Maybe! :D Maybe you're right. Anyhow, there should be a possibility to attach a stream to an existing file descriptor. So something like this can be implemented. It restricts what can be done with streams, when this isn't provided. Volker > > > > On Sat, 31 Aug 2024 at 17:48, Volker Wysk <[email protected]> wrote: > > Hi there > > > > Actually, I've been toying with the idea of writing something like this: > > > > :- pred run_program( > > string::in, % Path to executable > > bool::in, % Connect stdin? > > bool::in, % Connect stdout? > > bool::in, % Connect stderr? > > maybe(io.text_output_stream)::out, % Handle to program's stdin > > maybe(io.text_input_stream)::out, % Handle to program's stdout > > maybe(io.text_input_stream)::out, % Handle to program's stderr > > int::out % Child process's process id > > ) is det. > > > > For this to work, a predicate for attaching a stream to an existing file > > descriptor would be needed. It doesn't look like this is provided by the > > io/io.call_system libraries. > > > > I would be inclined to contribute this to the standard libraries, if > > that is > > welcome. I know that a high code quality would be required. > > > > Cheers > > Volker > > > > > > Am Samstag, dem 31.08.2024 um 16:35 +0200 schrieb Zoltan Somogyi: > > > > > > > > > On Sat, 31 Aug 2024 15:30:30 +0100, emacstheviking <[email protected]> > > > wrote: > > > > I have been reading io.system_call and cannot see how to capture the > > > > output > > > > into a string... was this ever possible? > > > > > > Assuming you are talking about io.call_system, the answer is "no". > > > > > > > Do I have pipe to a file myself then, then read and process the > > contents > > > > thus generated? > > > > > > Yes. > > > > > > Zoltan. > > _______________________________________________ users mailing list [email protected] https://lists.mercurylang.org/listinfo/users