* [9fans] newbie rc question
@ 2007-10-15 16:46 john
2007-10-15 17:22 ` erik quanstrom
0 siblings, 1 reply; 4+ messages in thread
From: john @ 2007-10-15 16:46 UTC (permalink / raw)
To: 9fans
So, after reading the Blit paper, I thought 'watch' looked pretty
neat and tried to make a simple rc script to act similarly. However,
when I use the script (at the end of this email) to try something
like this:
man -t ls > foo
watch foo | page
page says 'converting from troff to postscript' but then never
actually displays anything. I'm sure there's something basic
I'm forgetting here--can somebody help me figure out what's
wrong?
Here's the code (I apologize if it doesn't meet your standards)
#!/bin/rc
# Watch the specified file for changes; print out the file
# if there are any changes.
if (~ $#* 1) {
cat $1
sum = `{sum $1}
while () {
newsum = `{sum $1}
if (! ~ $sum(1) $newsum(1)) {
sum = $newsum
cat $1
}
sleep 1
}
}
if not {
echo 'Usage: watch <file>'
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [9fans] newbie rc question
2007-10-15 16:46 [9fans] newbie rc question john
@ 2007-10-15 17:22 ` erik quanstrom
2007-10-15 20:30 ` john
0 siblings, 1 reply; 4+ messages in thread
From: erik quanstrom @ 2007-10-15 17:22 UTC (permalink / raw)
To: 9fans
> page says 'converting from troff to postscript' but then never
> actually displays anything. I'm sure there's something basic
> I'm forgetting here--can somebody help me figure out what's
> wrong?
the file descriptor is never closed, thus page never stops to render
what it's got.
what you want is the same thing with the cmd rolled inside. something
like
#!/bin/rc
if(! ~ $#* 2){
echo usage: w file cmd >[1=2];
exit usage
}
s=''
while(){
n=`{sum $1| sed 's/ .*//g'}
if(! ~ $s $n){
s=$n
$2 < $1
}
sleep 1
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [9fans] newbie rc question
2007-10-15 17:22 ` erik quanstrom
@ 2007-10-15 20:30 ` john
2007-10-15 20:34 ` erik quanstrom
0 siblings, 1 reply; 4+ messages in thread
From: john @ 2007-10-15 20:30 UTC (permalink / raw)
To: 9fans
>> page says 'converting from troff to postscript' but then never
>> actually displays anything. I'm sure there's something basic
>> I'm forgetting here--can somebody help me figure out what's
>> wrong?
>
> the file descriptor is never closed, thus page never stops to render
> what it's got.
>
> what you want is the same thing with the cmd rolled inside. something
> like
>
> #!/bin/rc
>
> if(! ~ $#* 2){
> echo usage: w file cmd >[1=2];
> exit usage
> }
>
> s=''
> while(){
> n=`{sum $1| sed 's/ .*//g'}
> if(! ~ $s $n){
> s=$n
> $2 < $1
> }
> sleep 1
> }
This doesn't quite allow for the same possibilities as the original
Unix program seemed to, where you could do:
watch fig1.pic | pic | troff | page
instead of being limited to just one command. Can the problem of
open file descriptors be solved in rc while still giving a nice general
tool, or is it necessary to go to C?
John
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [9fans] newbie rc question
2007-10-15 20:30 ` john
@ 2007-10-15 20:34 ` erik quanstrom
0 siblings, 0 replies; 4+ messages in thread
From: erik quanstrom @ 2007-10-15 20:34 UTC (permalink / raw)
To: 9fans
> This doesn't quite allow for the same possibilities as the original
> Unix program seemed to, where you could do:
> watch fig1.pic | pic | troff | page
> instead of being limited to just one command. Can the problem of
> open file descriptors be solved in rc while still giving a nice general
> tool, or is it necessary to go to C?
>
>
> John
sure it does. you could replace the $2 < $1 in the script with
rc -c $2<$1
then your command would be
watch fig1.pic 'pic|troff|page'
- erik
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-10-15 20:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-15 16:46 [9fans] newbie rc question john
2007-10-15 17:22 ` erik quanstrom
2007-10-15 20:30 ` john
2007-10-15 20:34 ` erik quanstrom
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).