* [9fans] rc - how to...
@ 2002-09-12 14:03 steve.simon
0 siblings, 0 replies; 7+ messages in thread
From: steve.simon @ 2002-09-12 14:03 UTC (permalink / raw)
To: 9fans
Hi,
I like rc's language very much, but, I cannot work out how to
read a series of words from a slow running program, for example:
for ( file in `{du /} )
echo $file(1)
This runs the du and then processes the output of it.
I want to read du's output a line at a time so I get dataflow
and see the output of each line as they are processed.
I would use the read(1) command in Bourne shell but
cannot see an equivalent in rc.
Anyone help?
Thanks,
-Steve
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9fans] rc - how to...
@ 2002-09-12 14:10 Russ Cox
0 siblings, 0 replies; 7+ messages in thread
From: Russ Cox @ 2002-09-12 14:10 UTC (permalink / raw)
To: 9fans
du / | while(file=`{read})
echo $file
Russ
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9fans] rc - how to...
@ 2002-09-12 14:42 rog
0 siblings, 0 replies; 7+ messages in thread
From: rog @ 2002-09-12 14:42 UTC (permalink / raw)
To: 9fans
> du / | while(file=`{read})
> echo $file
it's probably worth mentioning that this is really quite slow, as the
read command is unable to do any IO buffering, must read one
character at a time, and is reloaded on every line of input:
on my machine,
while (file=`{read}) {}
exececutes about 85 lines a second, whereas a simple xargs-like
program processes about 4300.
this could be quite significant if you're using to process
output from du (what was viable in the old bourne
shell with
du . | while read x
do something with $x
done
is not necessarily fast enough in the rc equivalent)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9fans] rc - how to...
@ 2002-09-13 8:01 Fco.J.Ballesteros
0 siblings, 0 replies; 7+ messages in thread
From: Fco.J.Ballesteros @ 2002-09-13 8:01 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 127 bytes --]
Most of the times I wanted to do "while read { x }" I could
rewrite it to be "sed 's/^/x /' | rc", which works like a charm.
[-- Attachment #2: Type: message/rfc822, Size: 1699 bytes --]
From: rog@vitanuova.com
To: 9fans@cse.psu.edu
Subject: Re: [9fans] rc - how to...
Date: Thu, 12 Sep 2002 15:42:38 +0100
Message-ID: <35d1a51a345858e759eea904502ce78e@vitanuova.com>
> du / | while(file=`{read})
> echo $file
it's probably worth mentioning that this is really quite slow, as the
read command is unable to do any IO buffering, must read one
character at a time, and is reloaded on every line of input:
on my machine,
while (file=`{read}) {}
exececutes about 85 lines a second, whereas a simple xargs-like
program processes about 4300.
this could be quite significant if you're using to process
output from du (what was viable in the old bourne
shell with
du . | while read x
do something with $x
done
is not necessarily fast enough in the rc equivalent)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9fans] rc - how to...
@ 2002-09-13 13:50 rog
0 siblings, 0 replies; 7+ messages in thread
From: rog @ 2002-09-13 13:50 UTC (permalink / raw)
To: 9fans
> Most of the times I wanted to do "while read { x }" I could
> rewrite it to be "sed 's/^/x /' | rc", which works like a charm.
...until your input contains ";rm -rf *"...
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9fans] rc - how to...
@ 2002-09-13 14:09 Fco.J.Ballesteros
2002-09-14 0:16 ` Jim Choate
0 siblings, 1 reply; 7+ messages in thread
From: Fco.J.Ballesteros @ 2002-09-13 14:09 UTC (permalink / raw)
To: 9fans
If the input contains '; rm -rf *', I go and kill the user (not the
process). In a finite number of steps you get good input files.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9fans] rc - how to...
2002-09-13 14:09 Fco.J.Ballesteros
@ 2002-09-14 0:16 ` Jim Choate
0 siblings, 0 replies; 7+ messages in thread
From: Jim Choate @ 2002-09-14 0:16 UTC (permalink / raw)
To: 9fans
On Fri, 13 Sep 2002, Fco.J.Ballesteros wrote:
> If the input contains '; rm -rf *', I go and kill the user (not the
> process). In a finite number of steps you get good input files.
Or they kill you, which seems more likely. Users outnumber operators
by a considerable factor.
--
____________________________________________________________________
We don't see things as they are, ravage@ssz.com
we see them as we are. www.ssz.com
jchoate@open-forge.org
Anais Nin www.open-forge.org
--------------------------------------------------------------------
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2002-09-14 0:16 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-12 14:03 [9fans] rc - how to steve.simon
2002-09-12 14:10 Russ Cox
2002-09-12 14:42 rog
2002-09-13 8:01 Fco.J.Ballesteros
2002-09-13 13:50 rog
2002-09-13 14:09 Fco.J.Ballesteros
2002-09-14 0:16 ` Jim Choate
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 NNTP newsgroup(s).