* pipelines
@ 2009-03-28 12:53 Marijn Schouten (hkBst)
2009-03-29 6:24 ` pipelines Andy Wingo
2009-03-31 22:56 ` pipelines Ludovic Courtès
0 siblings, 2 replies; 5+ messages in thread
From: Marijn Schouten (hkBst) @ 2009-03-28 12:53 UTC (permalink / raw)
To: guile-user
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
how would I construct a pipeline with guile? Currently my best attempt which
turns to nothing is:
guile> (use-modules (ice-9 popen))
guile> (with-output-to-port (open-pipe "echo" OPEN_WRITE) (lambda ()
(with-input-from-port (open-pipe* OPEN_READ "echo" "Hello world") (lambda ()
(display (readline))))))
Marijn
- --
Gods do not want you to think, lest they lose existence.
Religions do not want you to think, lest they lose power.
Marijn Schouten (hkBst), Gentoo Lisp project, Gentoo ML
<http://www.gentoo.org/proj/en/lisp/>, #gentoo-{lisp,ml} on FreeNode
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAknOHckACgkQp/VmCx0OL2z2TQCgxPDaJTts5+myLJ1VlGofpFp8
FXsAnAzXQwMZAhoRacjgNr+G+u56WJ2h
=Z8GH
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: pipelines
2009-03-28 12:53 pipelines Marijn Schouten (hkBst)
@ 2009-03-29 6:24 ` Andy Wingo
2009-03-30 9:26 ` pipelines Marijn Schouten (hkBst)
2009-03-31 22:56 ` pipelines Ludovic Courtès
1 sibling, 1 reply; 5+ messages in thread
From: Andy Wingo @ 2009-03-29 6:24 UTC (permalink / raw)
To: Marijn Schouten (hkBst); +Cc: guile-user
Hi Marijn,
On Sat 28 Mar 2009 05:53, "Marijn Schouten (hkBst)" <hkBst@gentoo.org> writes:
> how would I construct a pipeline with guile? Currently my best attempt which
> turns to nothing is:
>
> guile> (use-modules (ice-9 popen))
> guile> (with-output-to-port (open-pipe "echo" OPEN_WRITE) (lambda ()
> (with-input-from-port (open-pipe* OPEN_READ "echo" "Hello world") (lambda ()
> (display (readline))))))
What do you mean by "pipeline"? Do you want to spawn off "echo foo |
bar", or write data to "bar", or read data from "echo foo" ?
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: pipelines
2009-03-29 6:24 ` pipelines Andy Wingo
@ 2009-03-30 9:26 ` Marijn Schouten (hkBst)
2009-03-30 19:00 ` pipelines Neil Jerram
0 siblings, 1 reply; 5+ messages in thread
From: Marijn Schouten (hkBst) @ 2009-03-30 9:26 UTC (permalink / raw)
To: Andy Wingo; +Cc: guile-user
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Andy Wingo wrote:
> Hi Marijn,
>
> On Sat 28 Mar 2009 05:53, "Marijn Schouten (hkBst)" <hkBst@gentoo.org> writes:
>
>> how would I construct a pipeline with guile? Currently my best attempt which
>> turns to nothing is:
>>
>> guile> (use-modules (ice-9 popen))
>> guile> (with-output-to-port (open-pipe "echo" OPEN_WRITE) (lambda ()
>> (with-input-from-port (open-pipe* OPEN_READ "echo" "Hello world") (lambda ()
>> (display (readline))))))
>
> What do you mean by "pipeline"? Do you want to spawn off "echo foo |
> bar", or write data to "bar", or read data from "echo foo" ?
>
> Andy
By pipeline I mean for example:
echo "Hello world" | cat | cat | cat | grep world | cat
I know how to create such pipelines that contain only a single pipe. My question
is about how to do it when there are many pipes.
Marijn
- --
Gods do not want you to think, lest they lose existence.
Religions do not want you to think, lest they lose power.
Marijn Schouten (hkBst), Gentoo Lisp project, Gentoo ML
<http://www.gentoo.org/proj/en/lisp/>, #gentoo-{lisp,ml} on FreeNode
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAknQkD0ACgkQp/VmCx0OL2xg9QCfXpQiYE8NRW3jwKXwWT2/CMeG
4T0AnjjtydzaLNQb7qBp639Qd2UqHbR4
=lAkP
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: pipelines
2009-03-30 9:26 ` pipelines Marijn Schouten (hkBst)
@ 2009-03-30 19:00 ` Neil Jerram
0 siblings, 0 replies; 5+ messages in thread
From: Neil Jerram @ 2009-03-30 19:00 UTC (permalink / raw)
To: Marijn Schouten (hkBst); +Cc: Andy Wingo, guile-user
"Marijn Schouten (hkBst)" <hkBst@gentoo.org> writes:
> By pipeline I mean for example:
>
> echo "Hello world" | cat | cat | cat | grep world | cat
>
> I know how to create such pipelines that contain only a single pipe. My question
> is about how to do it when there are many pipes.
I don't know the answer myself, but can I suggest looking at what
guile-scsh does? See http://arglist.com/guile.
Neil
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: pipelines
2009-03-28 12:53 pipelines Marijn Schouten (hkBst)
2009-03-29 6:24 ` pipelines Andy Wingo
@ 2009-03-31 22:56 ` Ludovic Courtès
1 sibling, 0 replies; 5+ messages in thread
From: Ludovic Courtès @ 2009-03-31 22:56 UTC (permalink / raw)
To: guile-user
Hello!
"Marijn Schouten (hkBst)" <hkBst@gentoo.org> writes:
> how would I construct a pipeline with guile?
Here's an idea:
(use-modules (ice-9 popen)
(srfi srfi-1))
(define (input-pipeline . args)
(fold (lambda (program input)
(with-input-from-port input
(lambda ()
(open-input-pipe program))))
(current-input-port)
args))
It can then be used like this:
(read-line (input-pipeline "echo foo" "cat" "cat"
"grep foo" "sed -es/foo/bar/g"))
=> "bar"
Defining `output-pipeline' is left as an exercise to the reader.
Thanks,
Ludo'.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-03-31 22:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-28 12:53 pipelines Marijn Schouten (hkBst)
2009-03-29 6:24 ` pipelines Andy Wingo
2009-03-30 9:26 ` pipelines Marijn Schouten (hkBst)
2009-03-30 19:00 ` pipelines Neil Jerram
2009-03-31 22:56 ` pipelines Ludovic Courtès
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).