* easy question: getting shell output?
@ 2002-04-26 16:02 Ciaran O'Riordan
2002-04-26 16:31 ` Christopher Cramer
2002-05-15 4:05 ` Thien-Thi Nguyen
0 siblings, 2 replies; 3+ messages in thread
From: Ciaran O'Riordan @ 2002-04-26 16:02 UTC (permalink / raw)
Hi all!
(I think this is my first post to the list)
I'm having a small problem capturing the output of
a shell command.
I want the output of 'ls -1' to be stored in a
variable which I will later split into a list.
I've tried the obvious things like changing the
default output port to a newly created string port
but no matter what I try the output always gets
displayed to my terminal.
This must be a common situation, I've read the
guile reference and the guile tutorial but can't
find an answer.
any pointers would be appreciated.
Ciaran O'Riordan
_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: easy question: getting shell output?
2002-04-26 16:02 easy question: getting shell output? Ciaran O'Riordan
@ 2002-04-26 16:31 ` Christopher Cramer
2002-05-15 4:05 ` Thien-Thi Nguyen
1 sibling, 0 replies; 3+ messages in thread
From: Christopher Cramer @ 2002-04-26 16:31 UTC (permalink / raw)
Cc: guile-user
On Fri, Apr 26, 2002 at 04:02:26PM +0000, Ciaran O'Riordan wrote:
> I'm having a small problem capturing the output of
> a shell command.
>
> I want the output of 'ls -1' to be stored in a
> variable which I will later split into a list.
>
> I've tried the obvious things like changing the
> default output port to a newly created string port
> but no matter what I try the output always gets
> displayed to my terminal.
The default output port is only used by Guile. A separate process
(such as ls) isn't going to use it.
What you probably want is open-input-pipe, e.g.:
(use-modules
(ice-9 rw)
(ice-9 popen))
(let (
(input (open-input-pipe "ls -1"))
(buffer (make-string 256)))
(let loop ((l '()))
(let ((n (read-string!/partial buffer input)))
(if n
(loop (cons (substring buffer 0 n) l))
(apply string-append (reverse! l))))))
--
Christopher Cramer <crayc@pyro.net> <http://www.pyro.net/~crayc/>
On résiste à l'invasion des armées; on ne résiste pas à l'invasion
des idées. -- Victor Hugo
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: easy question: getting shell output?
2002-04-26 16:02 easy question: getting shell output? Ciaran O'Riordan
2002-04-26 16:31 ` Christopher Cramer
@ 2002-05-15 4:05 ` Thien-Thi Nguyen
1 sibling, 0 replies; 3+ messages in thread
From: Thien-Thi Nguyen @ 2002-05-15 4:05 UTC (permalink / raw)
Cc: guile-user
From: "Ciaran O'Riordan" <ciaran_o_riordan@hotmail.com>
Date: Fri, 26 Apr 2002 16:02:26 +0000
any pointers would be appreciated.
you can use (ice-9 popen) facilities directly, or higher abstractions.
for examples of the latter, see (ttn make-buffered-caller) and friends:
http://www.glug.org/people/ttn/software/ttn-pers-scheme/dist/0.29/ttn/
make-buffered-caller is used in lots of places:
http://www.glug.org/maint/cron-job-map.html
probably i'll contribute make-buffered-caller to guile at some point.
thi
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-05-15 4:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-26 16:02 easy question: getting shell output? Ciaran O'Riordan
2002-04-26 16:31 ` Christopher Cramer
2002-05-15 4:05 ` Thien-Thi Nguyen
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).