9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] rc question
@ 2006-03-17 21:09 erik quanstrom
  2006-03-17 21:46 ` Lyndon Nerenberg
  2006-03-17 22:08 ` Charles Forsyth
  0 siblings, 2 replies; 23+ messages in thread
From: erik quanstrom @ 2006-03-17 21:09 UTC (permalink / raw)
  To: 9fans

to do a dns query directly, one needs to open /net/dns and write
the query and read the results on the same fd. how can this be
done with rc?

- erik


^ permalink raw reply	[flat|nested] 23+ messages in thread
* Re: [9fans] rc question
@ 2006-03-24 14:39 erik quanstrom
  2006-03-24 17:26 ` Ronald G Minnich
  0 siblings, 1 reply; 23+ messages in thread
From: erik quanstrom @ 2006-03-24 14:39 UTC (permalink / raw)
  To: 9fans

i think you're making this too complicated. you wouldn't want
to use <> with a real file. a fileserver like ndb/dns often ignores seeks.
why use a non-default file descriptor?

why wouldn't this work?

	<> /net/dns { echo google.com ip >[1=0] ; cat}

if you have a fileserver that does not ignore seeks, then this would work

	<> fspath { echo cmd ; syscall seek 0 0 0; cat}

- erik

rog@vitanuova.com writes

|
| geoff:
| > 	<>[4]/net/dns { echo google.com ip  >[1=4]; cat <[0=4] }
|
| if you're expecting the cat to start at offset 0, you'd be mistaken
| (the dup only ups the refcount on the underlying Chan,
| so the seek offsets are shared).
|
| cpu% echo one two three four five six > x
| cpu%
| cpu% <>[4] x {echo xxx >[1=4]; cat <[0=4]}
|  two three four five six
| cpu% cat x
| xxx
|  two three four five six
| cpu%
|
| you can probably do it with dd. the "read" command in inferno
| is a more direct analog of the system call, and allows a "-o" flag
| to set the offset. i found it quite often useful to know that one
| is getting one and only one (p)read.


^ permalink raw reply	[flat|nested] 23+ messages in thread
* Re: [9fans] rc question
@ 2006-03-18 13:02 erik quanstrom
  0 siblings, 0 replies; 23+ messages in thread
From: erik quanstrom @ 2006-03-18 13:02 UTC (permalink / raw)
  To: 9fans

i don't agree that a small program is in order. this is the type
of thing that is often done by hand, once. that's why god gave
us the shell. ;-)

i was thinking about this this am (before i'd read all the email
on the subject). perhaps this would be better:

	<>[1,2] /net/dns { echo google.com ip ; cat >[1=2] }

or this should work currently

	<> /net/dns { @{ >[1=0]  echo gogole.com ip} ; cat }

i like your suggestion, but i think that real variables would be
much better than creating a special namespace for file descriptors.
(how would they survive a fork, for instance. that's sure to come
up.) the other problem is how to deal with the syntax. the
syntax for redirection is already tricky.

on the subject of rc, i think there are a few other improvements
that whould clean up the language a bit. for instance
- a `` operator like byron's rc. as in
	y = 'a b		c'
	x = ``(' ' '	') {echo $y}
	whatis y
	y=(a b c)
there are other ways to do this which might be better. but
the basic problem in rc is that it's often difficult to set ifs right
where you need it and it ends up interfering with something else

- here documents could be removed. quoting is simple enough;
embedding a document by quoting. and here documents don't
work in functions. (this would require a small change to how tok
is handled.)

On Sat Mar 18 06:35:58 CST 2006, bruce.ellis@gmail.com wrote:
> i had a strange dream about something like ...
>
> >       <>[?]/net/dns { echo google.com ip  >[1=?1]; cat <[0=?1] }
>
> (just like \1, \2 etc in sam - change '?' to whatever you like.)
>
> in this case the first construct would do an open and the
> result may be 4 or 104 but "?1" will know.  and then it's over,
> as dup() is good for the rest.  it handles nesting and sequencing
> if you think about it.
>
> using fds beyond "i have one open so let's do some file-ops
> with it" is foolish.  both srv and ssl break this and hence can't
> fit in (can't be imported or exported).  writing a number (relevant
> only to the requesting machine) doesn't work from remote.
>
> check out the amusing error messages.
>
> brucee
>
> On 3/18/06, lucio@proxima.alt.za <lucio@proxima.alt.za> wrote:
> > > well it's a horrible ad-hoc hack.  do you expect it to work?
> >
> > It was before my first cup of coffee and I could not resist the
> > temptation.  The ";" complaint isn't yet clear to me, however.
> >
> > ++L
> >
> >


^ permalink raw reply	[flat|nested] 23+ messages in thread
* Re: [9fans] rc question
@ 2006-03-17 21:50 erik quanstrom
  0 siblings, 0 replies; 23+ messages in thread
From: erik quanstrom @ 2006-03-17 21:50 UTC (permalink / raw)
  To: 9fans

okay. right. i read the wrong (p9p) manual page.

- erik

On Fri Mar 17 15:48:16 CST 2006, lyndon@orthanc.ca wrote:
> > to do a dns query directly, one needs to open /net/dns and write
> > the query and read the results on the same fd. how can this be
> > done with rc?
>
> Something like
>
> <>[4]/dev/dns { echo foo >[4]; cat <[4] }
>
> ?
>
> I don't have a machine handy with which to test this ...



^ permalink raw reply	[flat|nested] 23+ messages in thread
* [9fans] rc question
@ 2006-03-17 21:06 erik quanstrom
  2006-06-30 18:23 ` Abhey Shah
  2006-06-30 18:33 ` matt
  0 siblings, 2 replies; 23+ messages in thread
From: erik quanstrom @ 2006-03-17 21:06 UTC (permalink / raw)


to do a dns query directly, one needs to open /net/dns and write
the query and read the results on the same fd. how can this be
done with rc?

- erik


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2006-06-30 20:06 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-17 21:09 [9fans] rc question erik quanstrom
2006-03-17 21:46 ` Lyndon Nerenberg
2006-03-18  6:20   ` lucio
2006-03-18  7:32     ` Bruce Ellis
2006-03-18  8:58       ` lucio
2006-03-18 12:34         ` Bruce Ellis
2006-03-18 13:30           ` lucio
2006-03-18  7:37     ` geoff
2006-03-18  7:38       ` Bruce Ellis
2006-03-18  9:02       ` lucio
2006-03-23 12:05       ` rog
2006-03-24  0:53         ` geoff
2006-03-17 22:08 ` Charles Forsyth
2006-03-17 22:11   ` Charles Forsyth
  -- strict thread matches above, loose matches on Subject: below --
2006-03-24 14:39 erik quanstrom
2006-03-24 17:26 ` Ronald G Minnich
2006-03-24 18:22   ` erik quanstrom
2006-03-18 13:02 erik quanstrom
2006-03-17 21:50 erik quanstrom
2006-03-17 21:06 erik quanstrom
2006-06-30 18:23 ` Abhey Shah
2006-06-30 18:33 ` matt
2006-06-30 20:06   ` quanstro

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).