From: "Bonface M. K." <bonfacemunyoki@gmail.com>
To: Roel Janssen <roel@gnu.org>
Cc: guile-user@gnu.org
Subject: Re: How do you record output of both STDERR and STDIN to a string?
Date: Thu, 10 Sep 2020 20:50:47 +0300 [thread overview]
Message-ID: <86y2lhldvs.fsf@gmail.com> (raw)
In-Reply-To: <4ede1fc86c21609bfb45dd3f33eaa64b7df785ba.camel@gnu.org> (Roel Janssen's message of "Thu, 10 Sep 2020 17:04:22 +0200")
[-- Attachment #1: Type: text/plain, Size: 1231 bytes --]
Hi!
Roel Janssen <roel@gnu.org> writes:
[...]
> Having spent a day on this myself, this is the best I had come up with:
>
> (define (virtuoso-isql-query query)
> "Executes QUERY via ISQL and returns a both an ERROR-PORT and a PORT
> to read CSV output from."
> (let* ((tmp (getenv "TMPDIR"))
> (error-port (mkstemp! (string-append (if tmp tmp "/tmp") "/sg-
> XXXXXX")))
> (port (open-input-pipe
> (format #f "~a ~a -U ~a -P ~a verbose=off
> csv_rfc4180=on csv_rfc4180_field_separator=, exec='~:a' 2> ~a"
> (isql-bin) (isql-port) (rdf-store-
> username)
> (rdf-store-password)
> (string-append "SPARQL " query)
> (port-filename error-port)))))
> (setvbuf port 'block 4096)
> (values error-port port)))
>
> I certainly hope someone can come up with a better solution!
>
Thanks. If I don't find anything, I'll give it a shot :)
> Kind regards,
> Roel Janssen
>
>
>
>
>
--
Bonface M. K. (https://www.bonfacemunyoki.com)
One Divine Emacs To Rule Them All
GPG key = D4F09EB110177E03C28E2FE1F5BBAE1E0392253F
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 869 bytes --]
prev parent reply other threads:[~2020-09-10 17:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-10 1:14 How do you record output of both STDERR and STDIN to a string? Bonface M. K.
2020-09-10 15:04 ` Roel Janssen
2020-09-10 17:48 ` Dr. Arne Babenhauserheide
2020-09-10 17:50 ` Bonface M. K. [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86y2lhldvs.fsf@gmail.com \
--to=bonfacemunyoki@gmail.com \
--cc=guile-user@gnu.org \
--cc=roel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).