* [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
* Re: [9fans] rc question
2006-03-17 21:06 [9fans] rc question erik quanstrom
@ 2006-06-30 18:23 ` Abhey Shah
2006-06-30 18:33 ` matt
1 sibling, 0 replies; 23+ messages in thread
From: Abhey Shah @ 2006-06-30 18:23 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
umm on inferno you can do
<>/net/dns {
echo -n ip www.google.com > [1=0];
addr:=`{read};
echo $addr
}
sorry thats not actually answering your question but I thought it might
be of some use.
Abhey
On 17 Mar 2006, at 21:06, erik quanstrom 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?
>
> - erik
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [9fans] rc question
2006-03-17 21:06 [9fans] rc question erik quanstrom
2006-06-30 18:23 ` Abhey Shah
@ 2006-06-30 18:33 ` matt
2006-06-30 20:06 ` quanstro
1 sibling, 1 reply; 23+ messages in thread
From: matt @ 2006-06-30 18:33 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
erik quanstrom 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?
>
>- erik
>
>
>
>
I've got the answer in my plan9 box but I dont have access to it until later
:)
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [9fans] rc question
2006-06-30 18:33 ` matt
@ 2006-06-30 20:06 ` quanstro
0 siblings, 0 replies; 23+ messages in thread
From: quanstro @ 2006-06-30 20:06 UTC (permalink / raw)
To: 9fans
the answer is with <>, as discussed before. i sent this email many months
ago. i believe it was marooned on a p9p upas queue from a machine that was
just recomissioned and was now sent because i sent another email via upas on
that machine.
- erik
On Fri Jun 30 13:34:09 CDT 2006, mattmobile@proweb.co.uk wrote:
> erik quanstrom 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?
> >
> >- erik
> >
> >
> >
> >
> I've got the answer in my plan9 box but I dont have access to it until later
>
> :)
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [9fans] rc question
2006-03-24 17:26 ` Ronald G Minnich
@ 2006-03-24 18:22 ` erik quanstrom
0 siblings, 0 replies; 23+ messages in thread
From: erik quanstrom @ 2006-03-24 18:22 UTC (permalink / raw)
To: 9fans, Ronald G Minnich
okay, the original martian was (i think):
Xmark
Xmark
Xmark
Xmark
Xword
"echo"
Xword
"google.com"
Xword
"ip"
Xconc
Xconc
Xsimple
Xmark
Xword
"cat"
Xsimple
0
0
Xrdwr
Xsimple
- erik
Ronald G Minnich <rminnich@lanl.gov> writes
|
| erik quanstrom wrote:
| > 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}
| >
|
|
| actually, this also probably reads better in Martian :-)
|
| ron
^ 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
2006-03-24 18:22 ` erik quanstrom
0 siblings, 1 reply; 23+ messages in thread
From: Ronald G Minnich @ 2006-03-24 17:26 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
erik quanstrom wrote:
> 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}
>
actually, this also probably reads better in Martian :-)
ron
^ 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-23 12:05 ` rog
@ 2006-03-24 0:53 ` geoff
0 siblings, 0 replies; 23+ messages in thread
From: geoff @ 2006-03-24 0:53 UTC (permalink / raw)
To: 9fans
> > <>[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).
Good point, I was thinking of /net/dns as a pipe or network connection
(which `<>' was added to rc to open), where seek offset is ignored.
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [9fans] rc question
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
2 siblings, 1 reply; 23+ messages in thread
From: rog @ 2006-03-23 12:05 UTC (permalink / raw)
To: 9fans
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 12:34 ` Bruce Ellis
@ 2006-03-18 13:30 ` lucio
0 siblings, 0 replies; 23+ messages in thread
From: lucio @ 2006-03-18 13:30 UTC (permalink / raw)
To: 9fans
> 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.
You really only need a /dev/fd/clone operation, don't you?
Simplistically:
fd=`cat /dev/fd/clone`
<>[$fd]/net/dns { echo google.com ip >[1=$fd]; cat <[0=$fd] }
Add syntactic sugar to taste.
++L
^ 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-18 8:58 ` lucio
@ 2006-03-18 12:34 ` Bruce Ellis
2006-03-18 13:30 ` lucio
0 siblings, 1 reply; 23+ messages in thread
From: Bruce Ellis @ 2006-03-18 12:34 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
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-18 7:37 ` geoff
2006-03-18 7:38 ` Bruce Ellis
@ 2006-03-18 9:02 ` lucio
2006-03-23 12:05 ` rog
2 siblings, 0 replies; 23+ messages in thread
From: lucio @ 2006-03-18 9:02 UTC (permalink / raw)
To: 9fans
> Right, it would have to be something like:
>
> <>[4]/net/dns { echo google.com ip >[1=4]; cat <[0=4] }
Ha, of course, that's why the ";" was unexpected! Modulo brucee's
perfectly legitimate complaint that fd-4 is dangerous to use. And
Plan 9 without a C compiler is an abomination, so a small program
would be justified here.
++L
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [9fans] rc question
2006-03-18 7:32 ` Bruce Ellis
@ 2006-03-18 8:58 ` lucio
2006-03-18 12:34 ` Bruce Ellis
0 siblings, 1 reply; 23+ messages in thread
From: lucio @ 2006-03-18 8:58 UTC (permalink / raw)
To: 9fans
> 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-18 7:37 ` geoff
@ 2006-03-18 7:38 ` Bruce Ellis
2006-03-18 9:02 ` lucio
2006-03-23 12:05 ` rog
2 siblings, 0 replies; 23+ messages in thread
From: Bruce Ellis @ 2006-03-18 7:38 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
looks better, geoff.
brucee
On 3/18/06, geoff@collyer.net <geoff@collyer.net> wrote:
> Right, it would have to be something like:
>
> <>[4]/net/dns { echo google.com ip >[1=4]; cat <[0=4] }
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [9fans] rc question
2006-03-18 6:20 ` lucio
2006-03-18 7:32 ` Bruce Ellis
@ 2006-03-18 7:37 ` geoff
2006-03-18 7:38 ` Bruce Ellis
` (2 more replies)
1 sibling, 3 replies; 23+ messages in thread
From: geoff @ 2006-03-18 7:37 UTC (permalink / raw)
To: 9fans
Right, it would have to be something like:
<>[4]/net/dns { echo google.com ip >[1=4]; cat <[0=4] }
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [9fans] rc question
2006-03-18 6:20 ` lucio
@ 2006-03-18 7:32 ` Bruce Ellis
2006-03-18 8:58 ` lucio
2006-03-18 7:37 ` geoff
1 sibling, 1 reply; 23+ messages in thread
From: Bruce Ellis @ 2006-03-18 7:32 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
well it's a horrible ad-hoc hack. do you expect it to work?
and gee i hope i'm not using fd 4 ... gee let's make it 40.
oh maybe i'm using that. etc.
brucee
On 3/18/06, lucio@proxima.alt.za <lucio@proxima.alt.za> wrote:
> >
> > Something like
> >
> > <>[4]/dev/dns { echo foo >[4]; cat <[4] }
> >
> > ?
> >
> > I don't have a machine handy with which to test this ...
>
> term% <>[4]/dev/dns { echo foo >[4]; cat <[4] }
> rc: #d/0: token ';': syntax error
>
> :-(
>
> ++L
>
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [9fans] rc question
2006-03-17 21:46 ` Lyndon Nerenberg
@ 2006-03-18 6:20 ` lucio
2006-03-18 7:32 ` Bruce Ellis
2006-03-18 7:37 ` geoff
0 siblings, 2 replies; 23+ messages in thread
From: lucio @ 2006-03-18 6:20 UTC (permalink / raw)
To: 9fans
>
> Something like
>
> <>[4]/dev/dns { echo foo >[4]; cat <[4] }
>
> ?
>
> I don't have a machine handy with which to test this ...
term% <>[4]/dev/dns { echo foo >[4]; cat <[4] }
rc: #d/0: token ';': syntax error
:-(
++L
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [9fans] rc question
2006-03-17 22:08 ` Charles Forsyth
@ 2006-03-17 22:11 ` Charles Forsyth
0 siblings, 0 replies; 23+ messages in thread
From: Charles Forsyth @ 2006-03-17 22:11 UTC (permalink / raw)
To: 9fans
> one tricky point is that you might need to seek to 0 between requests
that was a bit misleading: i meant read/write by `request':
the read might need to start at offset 0,
and perhaps that might be true of the write as well
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [9fans] rc question
2006-03-17 21:09 erik quanstrom
2006-03-17 21:46 ` Lyndon Nerenberg
@ 2006-03-17 22:08 ` Charles Forsyth
2006-03-17 22:11 ` Charles Forsyth
1 sibling, 1 reply; 23+ messages in thread
From: Charles Forsyth @ 2006-03-17 22:08 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 71 bytes --]
one tricky point is that you might need to seek to 0 between requests
[-- Attachment #2: Type: message/rfc822, Size: 2243 bytes --]
From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@cse.psu.edu
Subject: [9fans] rc question
Date: Fri, 17 Mar 2006 15:09:49 -0600 (CST)
Message-ID: <20060317210949.1D17711122@dexter-peak.quanstro.net>
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-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
* Re: [9fans] rc question
2006-03-17 21:09 erik quanstrom
@ 2006-03-17 21:46 ` Lyndon Nerenberg
2006-03-18 6:20 ` lucio
2006-03-17 22:08 ` Charles Forsyth
1 sibling, 1 reply; 23+ messages in thread
From: Lyndon Nerenberg @ 2006-03-17 21:46 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
> 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: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
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:06 [9fans] rc question erik quanstrom
2006-06-30 18:23 ` Abhey Shah
2006-06-30 18:33 ` matt
2006-06-30 20:06 ` quanstro
2006-03-17 21:09 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
2006-03-17 21:50 erik quanstrom
2006-03-18 13:02 erik quanstrom
2006-03-24 14:39 erik quanstrom
2006-03-24 17:26 ` Ronald G Minnich
2006-03-24 18:22 ` 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).