[9fans] awk help; not plan9 matter

2009-09-17 Thread Rudolf Sykora
Hello,

simple task.
I want to change the 2nd field on each line of a file, but preserve
the spacing of the lines.

If I do
  awk '{$2=hell; print}' file
the field gets changed, but all the spacing of the lines is gone; i.e.
any space is now just ' ' like this:
1  3 4   8
changes to
1 hell 4 8
while I need
1  hell 4   8.

Any help?
Thanks
Ruda



Re: [9fans] awk help; not plan9 matter

2009-09-17 Thread matt

sed 's/^([^ ]+ +)([^ ]+)/\1HELL/'


Hello,

simple task.
I want to change the 2nd field on each line of a file, but preserve
the spacing of the lines.

If I do
 awk '{$2=hell; print}' file
the field gets changed, but all the spacing of the lines is gone; i.e.
any space is now just ' ' like this:
1  3 4   8
changes to
1 hell 4 8
while I need
1  hell 4   8.

Any help?
Thanks
Ruda

 






Re: [9fans] Blocks in C

2009-09-17 Thread Charles Forsyth
we'd have been much better off if Apple had instead spent the
time and effort writing a decent iTunes, or opening their platform
interfaces enough that someone else could do it (and on Linux, not just Mac or 
Windows).



Re: [9fans] awk help; not plan9 matter

2009-09-17 Thread matt

awk '{a=$2; sub(a, hell); print}' file

also works if it contains no regex special chars 


this seems to do the trick otherwise

awk ' { p=substr($0, index($0,  )); split(p, a, [^ ]); sub(/ +[^ ]+/, , p); print 
$1 a[1] hell p} '



Rudolf Sykora wrote:


Hello,

simple task.
I want to change the 2nd field on each line of a file, but preserve
the spacing of the lines.

If I do
 awk '{$2=hell; print}' file
the field gets changed, but all the spacing of the lines is gone; i.e.
any space is now just ' ' like this:
1  3 4   8
changes to
1 hell 4 8
while I need
1  hell 4   8.

Any help?
Thanks
Ruda

 






Re: [9fans] Blocks in C

2009-09-17 Thread Daniel Lyons


On Sep 17, 2009, at 2:43 AM, Charles Forsyth wrote:


opening their platform interfaces


Any in particular?

—
Daniel Lyons




Re: [9fans] awk help; not plan9 matter

2009-09-17 Thread Rudolf Sykora
2009/9/17 matt maht-9f...@maht0x0r.net:
 awk '{a=$2; sub(a, hell); print}' file

The trouble with this is that the same string can appear more than
once (before, after the field, ...), so the simple substitution isn't
enough.
Ruda



[9fans] fun quote

2009-09-17 Thread erik quanstrom
i don't know how ingo managed to put his
finger on so many reasons i enjoy plan 9
by counterexample.

Linux is a 18+ years old kernel, there's not that
many easy projects left in it anymore :-/ Core kernel
features that look basic and which are not in Linux
yet often turn out to be not that simple.
-- Ingo Molnar

- erik



Re: [9fans] fun quote

2009-09-17 Thread Jack Norton

erik quanstrom wrote:

i don't know how ingo managed to put his
finger on so many reasons i enjoy plan 9
by counterexample.

Linux is a 18+ years old kernel, there's not that
many easy projects left in it anymore :-/ Core kernel
features that look basic and which are not in Linux
yet often turn out to be not that simple.
-- Ingo Molnar

- erik

  
Now, Plan 9's kernel is pretty old too, isn't it?  If Plan9 had become a 
bit more widely accepted, even as late as, let's say, 2002, do you think 
it would have become an unruly and frighteningly complicated beast as 
linux has?
What has saved other 'popular' kernels from this?  For instance, no body 
ever complains about FreeBSD being a complex cluster f***, but it has 
pretty wide adoption (even as a 'desktop').  What about OS X?  Has 
Apple's arrogance and secrecy saved it from  open source 
development?  It seems like they release code only after they are damn 
sure they've gotten all they can out of it. 
So, is Linux the unwanted poster-child of open source development?  I 
think an argument could be made. 


-Jack



Re: [9fans] awk help; not plan9 matter

2009-09-17 Thread yy
if you want to preserve white-space, you better forget about fields
and work with indexes on the string, match is your friend:

% echo '1  3 4   8' | awk '{match($0, /[ \t]*[^ \t]+[
\t]+/);a=RLENGTH+1;match(substr($0, a), /[ \t]/);print
substr($0,0,a-1) hell substr($0,RSTART+a)}'
1  hell 4   8

this is indeed a bit OT here, maybe next time you prefer trying in
#awk at freenode, where this kind of problems are welcomed

-- 
- yiyus || JGL . 4l77.com



[9fans] operator

2009-09-17 Thread Rudolf Sykora
Hello,

is the  operator a feature only of native plan 9?
It doesn't seem to work for me in p9p...
Is the right solution then, instead of

program  file

write

program  file  file_tmp
mv file_tmp file

?
Thanks
Ruda



Re: [9fans] fun quote

2009-09-17 Thread erik quanstrom
 Now, Plan 9's kernel is pretty old too, isn't it?

that's the point.  age is a red herring.

 What has saved other 'popular' kernels from this?  For instance, no body 
 ever complains about FreeBSD being a complex cluster, but it has 
 pretty wide adoption (even as a 'desktop').  What about OS X?  Has 
 Apple's arrogance and secrecy saved it from  open source 
 development?  It seems like they release code only after they are damn 
 sure they've gotten all they can out of it. 

so you're saying that osx is not complicated?

- erik



Re: [9fans] awk help; not plan9 matter

2009-09-17 Thread Rudolf Sykora
2009/9/17 yy yiyu@gmail.com:
 if you want to preserve white-space, you better forget about fields
 and work with indexes on the string, match is your friend:

 % echo '1      3 4           8' | awk '{match($0, /[ \t]*[^ \t]+[
 \t]+/);a=RLENGTH+1;match(substr($0, a), /[ \t]/);print
 substr($0,0,a-1) hell substr($0,RSTART+a)}'
 1      hell 4           8

Well, it's just so difficult for me to read this. :)
Also, i don't see how to easily modify it to flexibly work for any
(not known beforehand) column, as I need.
Why do you think this is better than my final solution?

 this is indeed a bit OT here, maybe next time you prefer trying in
 #awk at freenode, where this kind of problems are welcomed

I didn't know there is a separate channel for awk...

Thanks
Ruda



[9fans] plan9.bell-labs.com uptime reports

2009-09-17 Thread Eric Van Hensbergen
I setup pingdom to track plan9.bell-labs.com -- it routinely checks
from several probe server scattered across the world so its a good
resource to check when you are trying to see if its your problem or if
something is wrong at the Labs.  I've got an email notification relay
setup too, but haven't confirmed that its working.

The report is available here: http://www.pingdom.com/reports/ny7spbpcwjfu/
and the mailing list for the notification relay is here:
http://groups.google.com/group/9nag

(Yes, sources was down for 4 hours this morning)

  -eric



Re: [9fans] awk help; not plan9 matter

2009-09-17 Thread Noah Evans
Since you're doing character processing rather than record processing,
isn't C your best tool for the job here?

This is what I whipped out YMMV:

#include u.h
#include libc.h
#include bio.h

char *str;
int ntok;

#define WHITESPACE(c)   ((c) == ' ' || (c) == '\t' || (c) == '\n')

void
chgtok(Biobuf *bin, Biobuf *bout)
{
int seentok, waswhite, c;
seentok = 1;
waswhite = 0;

while((c = Bgetc(bin)) != Beof){
switch(c){
case ' ':
case '\t':
if(!waswhite){
seentok++;
waswhite = 1;
}
break;
case '\n':
seentok = 1;
break;
default:
waswhite = 0;
if(seentok == ntok){
Bprint(bout, str);
while((c = Bgetc(bin)) != Beof)
if(WHITESPACE(c))
break;
Bungetc(bin);
}
break;  
}
Bputc(bout, c);
}
Bflush(bout);
}

void
main(int argc, char **argv)
{
Biobuf bin, bout;

ARGBEGIN{
}ARGEND;
if(argc != 2)
sysfatal(usage);
ntok = atoi(argv[0]);
str = argv[1];
Binit(bin, 0, OREAD);
Binit(bout, 1, OWRITE);
chgtok(bin, bout);
exits(0);   
}




On Thu, Sep 17, 2009 at 10:23 AM, Rudolf Sykora rudolf.syk...@gmail.com wrote:
 Hello,

 simple task.
 I want to change the 2nd field on each line of a file, but preserve
 the spacing of the lines.

 If I do
  awk '{$2=hell; print}' file
 the field gets changed, but all the spacing of the lines is gone; i.e.
 any space is now just ' ' like this:
 1      3 4           8
 changes to
 1 hell 4 8
 while I need
 1      hell 4           8.

 Any help?
 Thanks
 Ruda





Re: [9fans] Blocks in C

2009-09-17 Thread LiteStar numnums
Like shuffle db (i.e. no iTunes).

On Thu, Sep 17, 2009 at 5:19 AM, Andrew Simmons kod...@gmail.com wrote:

  we'd have been much better off if Apple had instead spent the
  time and effort writing a decent iTunes

 And no doubt we'd have been much better off if Apple had instead spent the
 time and effort making a decent iPod.

 The iTunes on my computer strikes me as at worst perfectly decent, in
 general outstandingly good. What do you feel a decent iTunes should
 look like?




-- 
And in the Only Prolog programmers will find this funny department:

Q: How many Prolog programmers does it take to change a lightbulb?

A: No.
 -- Ovid

   By cosmic rule, as day yields night, so winter summer, war peace, plenty
famine. All things change. Air penetrates the lump of myrrh, until the
joining bodies die and rise again in smoke called incense.

   Men do not know how that which is drawn in different directions
harmonises with itself. The harmonious structure of the world depends upon
opposite tension like that of the bow and the lyre.

   This universe, which is the same for all, has not been made by any god
or man, but it always has been, is, and will be an ever-living fire,
kindling itself by regular measures and going out by regular measures
-- Heraclitus


Re: [9fans] awk help; not plan9 matter

2009-09-17 Thread roger peppe
another approach, build up a regexp and use that:

fn changefield {
n = $1
repl = $2
s=')([^ ]+)(.*)'
for(i in `{seq 1 `{echo $n 1 -p | dc}}){
s='[^   ]+[ ]+'^$s
}
s='('^$s
sed 's/'^$s^'/\1'^$repl^'\3/'
}

(N.B. if the replacement string
might contain / or \, those characters would need
quoting)



Re: [9fans] fun quote

2009-09-17 Thread Jack Norton

erik quanstrom wrote:

Now, Plan 9's kernel is pretty old too, isn't it?



that's the point.  age is a red herring.

  
What has saved other 'popular' kernels from this?  For instance, no body 
ever complains about FreeBSD being a complex cluster, but it has 
pretty wide adoption (even as a 'desktop').  What about OS X?  Has 
Apple's arrogance and secrecy saved it from  open source 
development?  It seems like they release code only after they are damn 
sure they've gotten all they can out of it. 



so you're saying that osx is not complicated?

- erik

  
No, no, it is, what I mean is that I haven't heard similar sentiments 
towards the open source released by Apple.   Apple's  'open source'  is  
software that is developed in a closed source fashion, then released as 
open source when the time is right, as opposed to Linux and related 
software, which are developed, almost from the ground up, as open 
source.  This is the impression I get anyway. 


-Jack



Re: [9fans] awk help; not plan9 matter

2009-09-17 Thread Lyndon Nerenberg - VE6BBM/VE7TFX
 The trouble with this is that the same string can appear more than
 once (before, after the field, ...), so the simple substitution isn't
 enough.

It's sounding like awk is the wrong tool. It should be trivial to code
up a short piece of C to do the job.




Re: [9fans] Blocks in C

2009-09-17 Thread David Leimbach
On Thu, Sep 17, 2009 at 1:43 AM, Charles Forsyth fors...@terzarima.netwrote:

 we'd have been much better off if Apple had instead spent the
 time and effort writing a decent iTunes, or opening their platform
 interfaces enough that someone else could do it (and on Linux, not just Mac
 or Windows).


What's your gripe on iTunes?  I've had a few issues with it, but it does
seem to get the job done somehow.  Honestly just curious.


Re: [9fans] fun quote

2009-09-17 Thread james toy
==8==
 No, no, it is, what I mean is that I haven't heard similar sentiments
 towards the open source released by Apple.   Apple's  'open source'  is
  software that is developed in a closed source fashion, then released as
 open source when the time is right, as opposed to Linux and related
 software, which are developed, almost from the ground up, as open source.
  This is the impression I get anyway.
==8==

Yes and no; a lot of xnu is derived from FreeBSD.  There are certainly
caveats and areas where this is not true; however, I believe that
anyone can get their hands on the source code whilst in development
with a premier apple developer account.  In some ways I understand
this method or source control and in others I do not.  It seems geared
to a more professional crowd because I highly doubt many people are
willing to shell out _thousands_ of dollars to get their hands on
source code ~6-12 months in advance. It seems more a company would be
willing to have an ADC account to get the xnu source early because
they need to provide updates to drivers etc etc etc..

james francis toy iv



Re: [9fans] fun quote

2009-09-17 Thread David Leimbach
On Thu, Sep 17, 2009 at 5:52 AM, erik quanstrom quans...@quanstro.netwrote:

  Now, Plan 9's kernel is pretty old too, isn't it?

 that's the point.  age is a red herring.

  What has saved other 'popular' kernels from this?  For instance, no body
  ever complains about FreeBSD being a complex cluster, but it has
  pretty wide adoption (even as a 'desktop').  What about OS X?  Has
  Apple's arrogance and secrecy saved it from  open source
  development?  It seems like they release code only after they are damn
  sure they've gotten all they can out of it.

 so you're saying that osx is not complicated?


I think Mach makes me go cross-eyed.  It's not at all what it was meant to
be.  Wedging that stuff in with IOKit and BSD stuff makes me feel lost, and
yes I've hacked on XNU, the hybrid beast that it is, and run Mac OS X on my
own kernels.



 - erik




Re: [9fans] fun quote

2009-09-17 Thread David Leimbach
On Thu, Sep 17, 2009 at 8:30 AM, Jack Norton j...@0x6a.com wrote:

 erik quanstrom wrote:

 Now, Plan 9's kernel is pretty old too, isn't it?



 that's the point.  age is a red herring.



 What has saved other 'popular' kernels from this?  For instance, no body
 ever complains about FreeBSD being a complex cluster, but it has pretty wide
 adoption (even as a 'desktop').  What about OS X?  Has Apple's arrogance and
 secrecy saved it from  open source development?  It seems like they
 release code only after they are damn sure they've gotten all they can out
 of it.


 so you're saying that osx is not complicated?

 - erik



 No, no, it is, what I mean is that I haven't heard similar sentiments
 towards the open source released by Apple.   Apple's  'open source'  is
  software that is developed in a closed source fashion, then released as
 open source when the time is right, as opposed to Linux and related
 software, which are developed, almost from the ground up, as open source.
  This is the impression I get anyway.
 -Jack

 As a former member of the OpenDarwin project, I can tell you your
impression of Apple's open source is pretty correct.  They like to share the
source, and people are allowed to port things they do to other platforms,
and submit patches and stuff gets into the mainline (like FreeBSD support
for libdispatch and such seems like it's going to).  Or you can just fork it
and make your own thing, but they're goal is probably the wider code review
that the community offers more so than sharing and being a nice open source
community member.
It is nice that they've started licensing some stuff under Apache instead of
some of their other licenses of the past, however I really feel Apple's open
source is more of a one-way street.

Dave


Re: [9fans] awk help; not plan9 matter

2009-09-17 Thread erik quanstrom
i don't know why this can't be done with sed.  if the
task is to just change the second field without messing
with whitespace, why doesn't this work

; cat x
1 3 4   8
1 2 3 4
; sed 's:^([^   ][  ]*)([^  ]):\1hell:g'  x
1 hell 48
1 hell  3 4

- erik



Re: [9fans] awk help; not plan9 matter

2009-09-17 Thread roger peppe
2009/9/17 erik quanstrom quans...@quanstro.net:
 i don't know why this can't be done with sed.  if the
 task is to just change the second field without messing
 with whitespace, why doesn't this work

indeed. i did the same thing (see previous post, except i've
just noticed that i forgot the ^ at the start of the regex).

BTW, no need for the g flag, i think.



Re: [9fans] fun quote

2009-09-17 Thread matt

look who's trolling now :)


i don't know how ingo managed to put his
finger on so many reasons i enjoy plan 9
by counterexample.

Linux is a 18+ years old kernel, there's not that
many easy projects left in it anymore :-/ Core kernel
features that look basic and which are not in Linux
yet often turn out to be not that simple.
-- Ingo Molnar

- erik

 






Re: [9fans] fun quote

2009-09-17 Thread erik quanstrom
On Thu Sep 17 12:28:18 EDT 2009, maht-9f...@maht0x0r.net wrote:
 look who's trolling now :)

if that's your opinion, then maybe you have
misunderstood my point.  perhaps i made it
poorly.

the plan 9 kernel often looks basic but is actually
quite sophisticated.  (this is even more true of
the fileserver kernel.)  it is also easy to understand
and modify.

it does not seem logical to assume that this point
is not widely a conviction that leads to action.

- erik



Re: [9fans] awk help; not plan9 matter

2009-09-17 Thread Rudolf Sykora
2009/9/17 erik quanstrom quans...@quanstro.net:
 i don't know why this can't be done with sed.  if the
 task is to just change the second field without messing
 with whitespace, why doesn't this work

As I said in my second post, neither the field (the problem with sed)
nor the string to be used as a replacement (no problem) is not known
in advance...
Apparently nobody reads but the 1st post... :)
Thanks!
Ruda



Re: [9fans] awk help; not plan9 matter

2009-09-17 Thread erik quanstrom
 As I said in my second post, neither the field (the problem with sed)
 nor the string to be used as a replacement (no problem) is not known
 in advance...
 Apparently nobody reads but the 1st post... :)

why would it be hard to build up the regular expression
with a script?

something like this (untested, getting lazy)

# usage: buildre n replacement
fn buildre {
re = '^'
for(i in `{seq 1 $1})
re = $re ^ '([^ ][  ]*)'
re = $re ^ ([^  ]):\' ^ $2 ^ ':'
}

- erik



Re: [9fans] awk help; not plan9 matter

2009-09-17 Thread Rudolf Sykora
2009/9/17 Noah Evans noah.ev...@gmail.com:
 Since you're doing character processing rather than record processing,
 isn't C your best tool for the job here?

 This is what I whipped out YMMV:

 #include u.h
 #include libc.h
 #include bio.h

 char *str;
 int ntok;

 #define WHITESPACE(c)           ((c) == ' ' || (c) == '\t' || (c) == '\n')

 void
 chgtok(Biobuf *bin, Biobuf *bout)
 {
        int seentok, waswhite, c;
        seentok = 1;
        waswhite = 0;

        while((c = Bgetc(bin)) != Beof){
                switch(c){
                case ' ':
                case '\t':
                        if(!waswhite){
                                seentok++;
                                waswhite = 1;
                        }
                        break;
                case '\n':
                        seentok = 1;
                        break;
                default:
                        waswhite = 0;
                        if(seentok == ntok){
                                Bprint(bout, str);
                                while((c = Bgetc(bin)) != Beof)
                                        if(WHITESPACE(c))
                                                break;
                                Bungetc(bin);
                        }
                        break;
                }
                Bputc(bout, c);
        }
        Bflush(bout);
 }

 void
 main(int argc, char **argv)
 {
        Biobuf bin, bout;

        ARGBEGIN{
        }ARGEND;
        if(argc != 2)
                sysfatal(usage);
        ntok = atoi(argv[0]);
        str = argv[1];
        Binit(bin, 0, OREAD);
        Binit(bout, 1, OWRITE);
        chgtok(bin, bout);
        exits(0);
 }


Thanks, terrific job. :)
But awk finally works (see my post at 12:46 or so) just fine and the
code is just straightforward 9 lines.
The only problem was to realize how one can proceed, i.e. here to
remember the individual spaces and reconstruct the line from the
fields.

Nonetheless, your solution is almost surely faster.

Thanks
Ruda



Re: [9fans] awk help; not plan9 matter

2009-09-17 Thread erik quanstrom
 # usage: buildre n replacement
 fn buildre {
   re = '^'
   for(i in `{seq 1 $1})
   re = $re ^ '([^ ][  ]*)'
   re = $re ^ ([^  ]):\' ^ $2 ^ ':'
 }

sorry.  quote snafu.

fn buildre {
re = 's:^'
for(i in `{seq 1 $1})
re = $re ^ '([^ ][  ]*)'
re = $re ^ '([^ ]):\' ^ $1 ^ $2 ^ :
}

- erik



Re: [9fans] awk help; not plan9 matter

2009-09-17 Thread Rudolf Sykora
2009/9/17 erik quanstrom quans...@quanstro.net:
 fn buildre {
        re = 's:^'
        for(i in `{seq 1 $1})
                re = $re ^ '([^         ][      ]*)'
        re = $re ^ '([^         ]):\' ^ $1 ^ $2 ^ :
 }

 - erik


Yes, I now see yours and Roger Peppe's idea to build a regexps and then use it.
That's true.
Only as I look at your code, not sure if it can stand possible spaces
at the beginning of a line, like
 1 2 3

Thanks
Ruda



Re: [9fans] Blocks in C

2009-09-17 Thread Daniel Lyons


On Sep 17, 2009, at 3:19 AM, Andrew Simmons wrote:

And no doubt we'd have been much better off if Apple had instead  
spent the

time and effort making a decent iPod.



Um... what is it you dislike about the iPod?

—
Daniel Lyons




Re: [9fans] Blocks in C

2009-09-17 Thread Jack Norton

David Leimbach wrote:



On Thu, Sep 17, 2009 at 1:43 AM, Charles Forsyth 
fors...@terzarima.net mailto:fors...@terzarima.net wrote:


we'd have been much better off if Apple had instead spent the
time and effort writing a decent iTunes, or opening their platform
interfaces enough that someone else could do it (and on Linux, not
just Mac or Windows).


What's your gripe on iTunes?  I've had a few issues with it, but it 
does seem to get the job done somehow.  Honestly just curious.

I'd like to jump in on this.
I hate iTunes with a passion. It is a huge monolithic godlike creature 
that tries to do everything for me (usually when I don't want it to).  
It brings my 12 powerbook to a screeching halt (I get beach balled to 
death), and it doesn't natively support many audio/video 
codecs/containers (and isn't that easily extended, which brings up 
quicktime   ). 
Then again, I grew up using winamp, and I absolutely love the old style 
winamp.   No bloody database, no crazy multi-tiered file browser, and no 
video player.  Just select a song(s) and play. 
Itunes is not a media player, it is a platform in and of itself.  It is 
the emacs of media players (in that it is all encompassing, there is a 
church/cult, etc...). 
Just about the simplest way to play audio on a computer, save for the 
methods in plan9 :)  (I'm _trying_ to get us back on topic...)
Ok I'm done. 


-Jack



Re: [9fans] awk help; not plan9 matter

2009-09-17 Thread roger peppe
2009/9/17 Rudolf Sykora rudolf.syk...@gmail.com:
 Yes, I now see yours and Roger Peppe's idea to build a regexps and then use 
 it.
 That's true.
 Only as I look at your code, not sure if it can stand possible spaces
 at the beginning of a line, like
     1 2     3

just change the regexp as required.



Re: [9fans] Blocks in C

2009-09-17 Thread Anant Narayanan

Not meaning to add fuel to the fire, but;

On Sep 17, 2009, at 7:38 PM, Jack Norton wrote:
I hate iTunes with a passion. It is a huge monolithic godlike  
creature that tries to do everything for me (usually when I don't  
want it to).  It brings my 12 powerbook to a screeching halt (I get  
beach balled to death), and it doesn't natively support many audio/ 
video codecs/containers (and isn't that easily extended, which  
brings up quicktime   ).


Somebody wrapped ffmpeg in Quicktime, which lets it play almost any  
imaginable media format: http://perian.org/


Quicktime X isn't too bad compared to the old QT, atleast they're  
making progress. You can't say the same of iTunes though, I think it's  
been going downhill since version 7. However, I do hope that when they  
decide to rewrite it in 64-bit Cocoa (iTunes X), they'll make it  
half as insane as compared to now. It's bound to happen.


 Just about the simplest way to play audio on a computer, save for  
the methods in plan9 :)  (I'm _trying_ to get us back on topic...)


Good luck trying to get Plan 9 to play video!

--
Anant




Re: [9fans] awk help; not plan9 matter

2009-09-17 Thread erik quanstrom
i don't think you need an extra () for the leading
white space.  just tack it on in with the leading expression.

the hoc is unnecessary.  just start with 2.

fn buildre {
re = 's:^([ ]*'
for(i in `{seq 2 $1})
re = $re ^ '[^  ]+[ ]+'
re = $re ^ ')([^]+):\1' ^ $2:
}

; buildre 1 hell
; whatis re
re='s:^([   ]*)([^  ]+):\1hell:'
; buildre 2 hell
; whatis re
re='s:^([   ]*[^]+[ ]+)([^  ]+):\1hell:'

- erik



Re: [9fans] Blocks in C

2009-09-17 Thread Akshat Kumar
 What I was referring to was Plan 9's ability
 (or lack thereof) to decode and play digital video codecs. Just one of those
 things that prevent someone from running only Plan 9 on their computers --
 you need one of the big 3 for web browser + video.

With Cinap Lenrek's work on linuxemu, one can use mplayer (with ffmpeg)
to play videos, and flash in browser works, so one can also watch videos
on Youtube.

Federico G. Benavento released a tool to play mpeg videos a while back.
It's not perfect and could use work.


... In case anyone is wondering what they could be doing instead of feeding
this massive thread more fatty foods.
ak



Re: [9fans] Blocks in C

2009-09-17 Thread erik quanstrom
 ... In case anyone is wondering what they could be doing instead of feeding
 this massive thread more fatty foods.

there's lots of complaining on the list about the
content of the list.

it's not like there aren't good meaty issues to discuss.
what happened with either of the recently-reported
fossil lockup problems, for instance?

i mentioned that the pool library can act as a big
kernel lock a few weeks ago.  i don't know if anyone
has thoughts on how to deal with this.

it seems to me we deserve the list we create.

- erik



Re: [9fans] Blocks in C

2009-09-17 Thread Uriel
http://ninetimes.cat-v.org/news/2009/09/07/0-mplayer9/

On Thu, Sep 17, 2009 at 10:31 PM, Anant Narayanan an...@kix.in wrote:
 On Sep 17, 2009, at 10:26 PM, erik quanstrom wrote:

 Good luck trying to get Plan 9 to play video!


 minooka; lc /sys/src/9/pc/*tv*.c
 devtv.c         vgatvp3020.c    vgatvp3026.c

 Sure, if you have a TV tuner. What I was referring to was Plan 9's ability
 (or lack thereof) to decode and play digital video codecs. Just one of those
 things that prevent someone from running only Plan 9 on their computers --
 you need one of the big 3 for web browser + video.

 --
 Anant






Re: [9fans] awk help; not plan9 matter

2009-09-17 Thread Rudolf Sykora
2009/9/17 erik quanstrom quans...@quanstro.net:
 i don't think you need an extra () for the leading
 white space.  just tack it on in with the leading expression.

see below

 the hoc is unnecessary.  just start with 2.
true :)

 fn buildre {
        re = 's:^([     ]*'
        for(i in `{seq 2 $1})
                re = $re ^ '[^  ]+[     ]+'
        re = $re ^ ')([^        ]+):\1' ^ $2:
 }

 ; buildre 1 hell
 ; whatis re
 re='s:^([       ]*)([^  ]+):\1hell:'

already here is a problem:
1) I am to save the leading space --- so it shouldn't be an argument to s.
2) only the 2nd () --- the word with no spaces in itself --- is to be changed
... since the spaces are to be preserved, none of them should be an
argument to the s command, I think. That's why it was treated
seperately by me.

Anyway, what do you think about that problem with the empty group? Why
linux is ok with it while plan 9 is not? Is there any reason? Is that
a bug in plan9 sed?

Thanks
Ruda

 ; buildre 2 hell
 ; whatis re
 re='s:^([       ]*[^    ]+[     ]+)([^  ]+):\1hell:'

 - erik





Re: [9fans] awk help; not plan9 matter

2009-09-17 Thread erik quanstrom
 Anyway, what do you think about that problem with the empty group? Why
 linux is ok with it while plan 9 is not? Is there any reason? Is that
 a bug in plan9 sed?

it is not a bug.  see regexp(6).  there is no production in the
grammar that allows ().

- erik



Re: [9fans] awk help; not plan9 matter

2009-09-17 Thread Rudolf Sykora
forget about my previous post regarding the leading space,
I am tired, it was wrong...

Anyway the question about () is still hot...
R

2009/9/17 Rudolf Sykora rudolf.syk...@gmail.com:
 2009/9/17 erik quanstrom quans...@quanstro.net:
 i don't think you need an extra () for the leading
 white space.  just tack it on in with the leading expression.

 see below

 the hoc is unnecessary.  just start with 2.
 true :)

 fn buildre {
        re = 's:^([     ]*'
        for(i in `{seq 2 $1})
                re = $re ^ '[^  ]+[     ]+'
        re = $re ^ ')([^        ]+):\1' ^ $2:
 }

 ; buildre 1 hell
 ; whatis re
 re='s:^([       ]*)([^  ]+):\1hell:'

 already here is a problem:
 1) I am to save the leading space --- so it shouldn't be an argument to s.
 2) only the 2nd () --- the word with no spaces in itself --- is to be changed
 ... since the spaces are to be preserved, none of them should be an
 argument to the s command, I think. That's why it was treated
 seperately by me.

 Anyway, what do you think about that problem with the empty group? Why
 linux is ok with it while plan 9 is not? Is there any reason? Is that
 a bug in plan9 sed?

 Thanks
 Ruda

 ; buildre 2 hell
 ; whatis re
 re='s:^([       ]*[^    ]+[     ]+)([^  ]+):\1hell:'

 - erik






[9fans] Standalone Hyper-V

2009-09-17 Thread Lyndon Nerenberg - VE6BBM/VE7TFX
Has anyone taken a crack at running a current Plan 9 under
Microsoft's standalone Hyper-V distribution? It's been a year
and a month since this last came up on the list, and a lot has
happened since then ...

--lyndon




Re: [9fans] Blocks in C

2009-09-17 Thread Steve Simon
 what happened with either of the recently-reported
 fossil lockup problems, for instance?

As I now have two servers at home (old and new) I have been trying
to provoke the old one into locking up so I can take a snap of its fossil.

sadly the old server has been irriatingly reliable and the only lockup
I have had so far was on the new machine (typical!).

If anyone has any thoughts/hints/guesses on how to provoke the fossil
lockup I would be very interested to hear. I have tried mirroring
sources which used to be a rich source of lockups but it seems to work now.

I am going to try sending this machine fake emails I have a feeling that
that can annoy fossil, and also speed up the rate of taking temporary
snaps which others have reported as being a source of problems.

-Steve



Re: [9fans] Blocks in C

2009-09-17 Thread Roman V Shaposhnik
On Thu, 2009-09-17 at 17:02 -0400, erik quanstrom wrote:
  ... In case anyone is wondering what they could be doing instead of feeding
  this massive thread more fatty foods.
 
 there's lots of complaining on the list about the
 content of the list.
 
 it's not like there aren't good meaty issues to discuss.
 what happened with either of the recently-reported
 fossil lockup problems, for instance?
 
 i mentioned that the pool library can act as a big
 kernel lock a few weeks ago.  i don't know if anyone
 has thoughts on how to deal with this.
 
 it seems to me we deserve the list we create.

I think you're right. Perhaps different folks are approaching
9fans with different assumptions, though. I see 3 camps present:
   1. The actual *developers* of the technology related to
   Plan 9. That would include you, Russ, Inferno folks and
   perhaps Nemo  co.

   2. The actual users of Plan9.

   3. The folks who do not use Plan9 in day-to-day life, but
   are fundamentally convinced in a WWP9D (what would Plan 9 do)
   principle.

And, of course, there are also trolls.

Trolls, aside, it looks like #1 and #2 might be slightly misaligned
with #3. At least my personal experience of getting frustrated on
9fans comes mostly from the cases where I didn't positioned my
question as the WWP9D one.

It would be easy to say that list should be divided, in practice
though, I'm not sure the folks who I would like to have a privilege
of addressing would voluntarily subscribe to the #3 type of list.

Thanks,
Roman.




[9fans] Netbooting from Qemu

2009-09-17 Thread Jerome Ibanes
Hi,

I am (net)booting a Qemu instance from a Plan 9 fileserver named
colossus(192.168.1.40) running cwfs, an authserver, named
cerberus(192.168.1.50) is also present in the same domain.

The client is named cpu-003(192.168.1.33), it retrieves, via dhcp its
plan9.ini, which is as such:

  bootfile=ether0!/386/9pccpu.gz
  bootargs=tcp!192.168.1.40!564 -D
  fs=192.168.1.40
  auth=192.168.1.50
  sysname=cpu-003
  *nomp=1
  *debugload=1
  *nodumpstack=1

The dhcpd configuration uses /lib/ndb/local to properly serve dhcp
queries, relevants bits as follow:

  ipnet=drawterm.com ip=192.168.1.0 ipmask=255.255.255.0
dnsdomain=drawterm.com
authdom=drawterm.com
ipgw=192.168.1.1
dns=192.168.1.1
ntp=192.168.1.1
auth=cerberus
fs=colossus
cpu=cpu-001
smtp=192.168.1.1

  ip=192.168.1.33 sys=cpu-003 ether=525400123456
dom=drawterm.com
bootf=/386/9pxeload
proto=tcp

When booting a 9pc kernel (which means that bootfile=ether0!/386/9pc.gz)
the system boots, then prompt for a user login, secstore password and
behaves as a terminal, as one can expect.

When booting a 9pccpu kernel (with the configuration above, and not
another change from the 9pc kernel) the system hangs as such (please
notice that I have ipconfig debug mode turned on in the bootargs):

  [...]
  ipconfig: parsebootp: new packet
  ipconfig: parseoptions: type(53) len 1, bytes left 71
  ipconfig: parseoptions: lease(51) len 4, bytes left 68
  ipconfig: parseoptions: serverid(54) len 4, bytes left 62
  ipconfig: parseoptions: ipmask(1) len 4, bytes left 56
  ipconfig: parseoptions: ipgw(3) len 4, bytes left 50
  ipconfig: parseoptions: sys(12) len 12, bytes left 44
  ipconfig: parseoptions: dns(6) len 4, bytes left 30
  ipconfig: parseoptions: dom(15) len 3, bytes left 24
  ipconfig: parseoptions: ntp(42) len 4, bytes left 19
  ipconfig: parseoptions: nil(43) len 12, bytes left 13
  ipconfig: got ack from 192.168.1.40
  ipconfig: lease=1800
  ipconfig: ipaddr=192.168.1.33 ipmask=255.255.255.0
  ipconfig: ipgw=192.168.1.1
  ipconfig: dns=192.168.1.1
  ipconfig: ntp=192.168.1.1
  ipconfig: parseoptions: nil(128) len 4, bytes left 10
  ipconfig: parseoptions: nil(129) len 4, bytes left 4
  ipconfig: fs=192.168.1.40
  ipconfig: auth=192.168.1.50
  ipconfig: new ipaddr=192.168.1.33 new ipmask=255.255.255.0 new 
ipgw=192.168.1.1
  ipconfig: server=192.168.1.40 sname=colossus

Then the system hangs, the cwfs console reports that no connection was
established from cpu-003(192.168.1.33), while, when booting a 9pc kernel,
the connection is established and the boot sequence follows.

Finally, replacing 'tcp!192.168.1.40!564' by 'tcp' or 'tcp!colossus!564'
leads to the same results, I do not believe it to be a misconfiguration
however as 9pc is booting properly.

Despite that 9pccpu is hanging, I am able to ping this host
cpu-003(192.168.1.33) therefore the network card has been found and
initialized properly. A 'snoopy' reports that after the last dhcp queries,
no packets are ever sent from cpu-003(192.168.1.33).

What would cause this configuration to boot using a stock 9pc kernel but
not a 9pccpu one? I've even increased the memory allocation of the Qemu
instance as I would expect a 9pccpu kernel to be slightly bigger than a
9pc one.


Any suggestion?
  Jerome



Re: [9fans] Netbooting from Qemu

2009-09-17 Thread erik quanstrom
   bootfile=ether0!/386/9pccpu.gz
   bootargs=tcp!192.168.1.40!564 -D
   fs=192.168.1.40
   auth=192.168.1.50
   sysname=cpu-003
   *nomp=1
   *debugload=1
   *nodumpstack=1

i think that should be should be (indent for clarity)

bootfile=ether0!$mydhcpserver!/386/9pccpu.gz
nobootprompt=tcp

otherwise i believe you will be prompted on the
console for a root fs.

also, you would be much better off creating a ipnet
entry in ndb.  i have a dim recollection of having trouble
when this was set up incorrectly, causing cs confusion.
setting the ipnet stuff allows the fs ip addr to be
inferred.

in your case, you want entries something like this:

ipnet=mynet ip=192.168.1.0 ipmask=/120
fs=myfs.example.net
ipgw=192.168.1.?
gw=mygw.example.net
dns=192.168.1.40
dnsdomain=example.net
authdom=myauthdom
auth=myfs
cpu=myfs

sys=mygw ip=192.168.1.? ether=000102030405
dom=mygw.example.net

sys=myfs ip=192.168.1.40 ether=000102030405
dom=myfs.example.net

sys=cpu-003 ip=192.168.1.33 ether=000102030405
dom=cpu-003.example.net
bootf=/386/9pxeload

- erik



Re: [9fans] Blocks in C

2009-09-17 Thread Daniel Lyons

It would be easy to say that list should be divided, in practice
though, I'm not sure the folks who I would like to have a privilege
of addressing would voluntarily subscribe to the #3 type of list.



Being a curious sometime user I guess I fall in category 3. Which  
seems natural since the list is called 9fans not plan9-dev. Not  
sure our community is large enough to survive being partitioned off  
into little tiny segments.


—
Daniel Lyons