9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] writing to /dev/$winid/addr
@ 2014-04-22 13:53 Alexander Kapshuk
  2014-04-23  7:29 ` Alexander Kapshuk
  0 siblings, 1 reply; 10+ messages in thread
From: Alexander Kapshuk @ 2014-04-22 13:53 UTC (permalink / raw)
  To: 9fans

Howdy,

I'm working on a script where I want to get hold of a particular string
and use it as a new name of a particular window.

What I've tried so far, although not successfully, is writing to
/dev/$winid/addr with the intention of then being able to read the
string found from the /dev/$winid/data or /dev/$winid/xdata.

acme(4) says,
addr        may be written with any textual address (line number,
               regular expression, etc.), in the format understood by
               button 3 but without the initial colon, including com-
               pound addresses, to set the address for text accessed
               through the data file.

Here's an example of what I tried.
echo '/[A-Z]+\![a-z0-9]+\![0-9a-z]+' >/dev/$winid/addr

Which results in an 'address out of bounds' message being generated.

How does one write to 'addr'? Clearly, the shortcoming is on my part.
I'm just not sure what it is that's missing.

Thanks.




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

* Re: [9fans] writing to /dev/$winid/addr
  2014-04-22 13:53 [9fans] writing to /dev/$winid/addr Alexander Kapshuk
@ 2014-04-23  7:29 ` Alexander Kapshuk
  2014-04-23 17:03   ` Bence Fábián
  0 siblings, 1 reply; 10+ messages in thread
From: Alexander Kapshuk @ 2014-04-23  7:29 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Turns out, the reason why writing '/[A-Z]+\![a-z0-9]+\![0-9a-z]+' to
/dev/$winid/addr would fail for me is because sending a string
represented by the regular expression in question to /dev/$winid/body
was immediately followed by writing the regexp to addr. Putting a
while loop on the 'echo regexp >addr' followed by sleep, seems to have
been the answer. The script sets the prompt and the name of the window
running win when logged onto a UNIX machine.
Here's the script for those interested.

#!/bin/rc
{
 echo 'echo $SYSNAME!`uname -n`!$USER'
 echo 'PS1='':; '' PS2='' '''
} >/dev/$winid/body
while(! echo -n '/[A-Z]+\![a-z0-9]+\![0-9a-z]+' >/dev/$winid/addr >[2]/dev/null)
 sleep 0.2
sel=`{cat /dev/$winid/xdata}
echo name $sel >/dev/$winid/ctl

On Tue, Apr 22, 2014 at 4:53 PM, Alexander Kapshuk
<alexander.kapshuk@gmail.com> wrote:
> Howdy,
>
> I'm working on a script where I want to get hold of a particular string
> and use it as a new name of a particular window.
>
> What I've tried so far, although not successfully, is writing to
> /dev/$winid/addr with the intention of then being able to read the
> string found from the /dev/$winid/data or /dev/$winid/xdata.
>
> acme(4) says,
> addr        may be written with any textual address (line number,
>                regular expression, etc.), in the format understood by
>                button 3 but without the initial colon, including com-
>                pound addresses, to set the address for text accessed
>                through the data file.
>
> Here's an example of what I tried.
> echo '/[A-Z]+\![a-z0-9]+\![0-9a-z]+' >/dev/$winid/addr
>
> Which results in an 'address out of bounds' message being generated.
>
> How does one write to 'addr'? Clearly, the shortcoming is on my part.
> I'm just not sure what it is that's missing.
>
> Thanks.
>



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

* Re: [9fans] writing to /dev/$winid/addr
  2014-04-23  7:29 ` Alexander Kapshuk
@ 2014-04-23 17:03   ` Bence Fábián
  2014-04-23 18:07     ` erik quanstrom
  0 siblings, 1 reply; 10+ messages in thread
From: Bence Fábián @ 2014-04-23 17:03 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 2129 bytes --]

is '!' a metacharacter in regexes? regex(6) doesn't say anything about it.



2014-04-23 9:29 GMT+02:00 Alexander Kapshuk <alexander.kapshuk@gmail.com>:

> Turns out, the reason why writing '/[A-Z]+\![a-z0-9]+\![0-9a-z]+' to
> /dev/$winid/addr would fail for me is because sending a string
> represented by the regular expression in question to /dev/$winid/body
> was immediately followed by writing the regexp to addr. Putting a
> while loop on the 'echo regexp >addr' followed by sleep, seems to have
> been the answer. The script sets the prompt and the name of the window
> running win when logged onto a UNIX machine.
> Here's the script for those interested.
>
> #!/bin/rc
> {
>  echo 'echo $SYSNAME!`uname -n`!$USER'
>  echo 'PS1='':; '' PS2='' '''
> } >/dev/$winid/body
> while(! echo -n '/[A-Z]+\![a-z0-9]+\![0-9a-z]+' >/dev/$winid/addr
> >[2]/dev/null)
>  sleep 0.2
> sel=`{cat /dev/$winid/xdata}
> echo name $sel >/dev/$winid/ctl
>
> On Tue, Apr 22, 2014 at 4:53 PM, Alexander Kapshuk
> <alexander.kapshuk@gmail.com> wrote:
> > Howdy,
> >
> > I'm working on a script where I want to get hold of a particular string
> > and use it as a new name of a particular window.
> >
> > What I've tried so far, although not successfully, is writing to
> > /dev/$winid/addr with the intention of then being able to read the
> > string found from the /dev/$winid/data or /dev/$winid/xdata.
> >
> > acme(4) says,
> > addr        may be written with any textual address (line number,
> >                regular expression, etc.), in the format understood by
> >                button 3 but without the initial colon, including com-
> >                pound addresses, to set the address for text accessed
> >                through the data file.
> >
> > Here's an example of what I tried.
> > echo '/[A-Z]+\![a-z0-9]+\![0-9a-z]+' >/dev/$winid/addr
> >
> > Which results in an 'address out of bounds' message being generated.
> >
> > How does one write to 'addr'? Clearly, the shortcoming is on my part.
> > I'm just not sure what it is that's missing.
> >
> > Thanks.
> >
>
>

[-- Attachment #2: Type: text/html, Size: 2900 bytes --]

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

* Re: [9fans] writing to /dev/$winid/addr
  2014-04-23 17:03   ` Bence Fábián
@ 2014-04-23 18:07     ` erik quanstrom
  2014-04-23 19:13       ` Alexander Kapshuk
  0 siblings, 1 reply; 10+ messages in thread
From: erik quanstrom @ 2014-04-23 18:07 UTC (permalink / raw)
  To: 9fans

> is '!' a metacharacter in regexes? regex(6) doesn't say anything about it.
>

it is not.

however

> > #!/bin/rc
> > {
> >  echo 'echo $SYSNAME!`uname -n`!$USER'
> >  echo 'PS1='':; '' PS2='' '''
> > } >/dev/$winid/body

this is not valid rc.

- erik



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

* Re: [9fans] writing to /dev/$winid/addr
  2014-04-23 18:07     ` erik quanstrom
@ 2014-04-23 19:13       ` Alexander Kapshuk
  2014-04-23 19:34         ` erik quanstrom
  0 siblings, 1 reply; 10+ messages in thread
From: Alexander Kapshuk @ 2014-04-23 19:13 UTC (permalink / raw)
  To: 9fans


On 04/23/2014 09:07 PM, erik quanstrom wrote:
>> is '!' a metacharacter in regexes? regex(6) doesn't say anything about it.
>>
> it is not.
>
> however
>
>>> #!/bin/rc
>>> {
>>>  echo 'echo $SYSNAME!`uname -n`!$USER'
>>>  echo 'PS1='':; '' PS2='' '''
>>> } >/dev/$winid/body
> this is not valid rc.
>
> - erik
>
If it's not too much trouble, would you mind demonstrating what valid rc
would be for the part of the script in question.

Thanks.




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

* Re: [9fans] writing to /dev/$winid/addr
  2014-04-23 19:13       ` Alexander Kapshuk
@ 2014-04-23 19:34         ` erik quanstrom
  2014-04-24  4:15           ` Alexander Kapshuk
  0 siblings, 1 reply; 10+ messages in thread
From: erik quanstrom @ 2014-04-23 19:34 UTC (permalink / raw)
  To: 9fans

> >>> #!/bin/rc
> >>> {
> >>>  echo 'echo $SYSNAME!`uname -n`!$USER'
> >>>  echo 'PS1='':; '' PS2='' '''
> >>> } >/dev/$winid/body
> > this is not valid rc.
> >
> > - erik
> >
> If it's not too much trouble, would you mind demonstrating what valid rc
> would be for the part of the script in question.

i'm wrong of course if the shell you're running is bash,
the script itself is reasonable rc.  i was confused by an
rc script emitting bash.

- erik



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

* Re: [9fans] writing to /dev/$winid/addr
  2014-04-23 19:34         ` erik quanstrom
@ 2014-04-24  4:15           ` Alexander Kapshuk
  2014-04-24  4:18             ` Jacob Todd
  0 siblings, 1 reply; 10+ messages in thread
From: Alexander Kapshuk @ 2014-04-24  4:15 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

That's OK. It's actually ksh on AIX.

Thanks for your feedback anyway.


On Wed, Apr 23, 2014 at 10:34 PM, erik quanstrom <quanstro@quanstro.net> wrote:
>> >>> #!/bin/rc
>> >>> {
>> >>>  echo 'echo $SYSNAME!`uname -n`!$USER'
>> >>>  echo 'PS1='':; '' PS2='' '''
>> >>> } >/dev/$winid/body
>> > this is not valid rc.
>> >
>> > - erik
>> >
>> If it's not too much trouble, would you mind demonstrating what valid rc
>> would be for the part of the script in question.
>
> i'm wrong of course if the shell you're running is bash,
> the script itself is reasonable rc.  i was confused by an
> rc script emitting bash.
>
> - erik
>



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

* Re: [9fans] writing to /dev/$winid/addr
  2014-04-24  4:15           ` Alexander Kapshuk
@ 2014-04-24  4:18             ` Jacob Todd
  2014-04-24  4:25               ` Alexander Kapshuk
  0 siblings, 1 reply; 10+ messages in thread
From: Jacob Todd @ 2014-04-24  4:18 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 848 bytes --]

Then why did you say it was rc? What's wrong with you.
On Apr 24, 2014 12:18 AM, "Alexander Kapshuk" <alexander.kapshuk@gmail.com>
wrote:

> That's OK. It's actually ksh on AIX.
>
> Thanks for your feedback anyway.
>
>
> On Wed, Apr 23, 2014 at 10:34 PM, erik quanstrom <quanstro@quanstro.net>
> wrote:
> >> >>> #!/bin/rc
> >> >>> {
> >> >>>  echo 'echo $SYSNAME!`uname -n`!$USER'
> >> >>>  echo 'PS1='':; '' PS2='' '''
> >> >>> } >/dev/$winid/body
> >> > this is not valid rc.
> >> >
> >> > - erik
> >> >
> >> If it's not too much trouble, would you mind demonstrating what valid rc
> >> would be for the part of the script in question.
> >
> > i'm wrong of course if the shell you're running is bash,
> > the script itself is reasonable rc.  i was confused by an
> > rc script emitting bash.
> >
> > - erik
> >
>
>

[-- Attachment #2: Type: text/html, Size: 1417 bytes --]

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

* Re: [9fans] writing to /dev/$winid/addr
  2014-04-24  4:18             ` Jacob Todd
@ 2014-04-24  4:25               ` Alexander Kapshuk
  2014-04-25  6:35                 ` Bence Fábián
  0 siblings, 1 reply; 10+ messages in thread
From: Alexander Kapshuk @ 2014-04-24  4:25 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

I'm sorry I confused you. In my second email I did mention that the
script was used to set a prompt and an acme window name when running
win and being logged onto UNIX.


On Thu, Apr 24, 2014 at 7:18 AM, Jacob Todd <jaketodd422@gmail.com> wrote:
> Then why did you say it was rc? What's wrong with you.
>
> On Apr 24, 2014 12:18 AM, "Alexander Kapshuk" <alexander.kapshuk@gmail.com>
> wrote:
>>
>> That's OK. It's actually ksh on AIX.
>>
>> Thanks for your feedback anyway.
>>
>>
>> On Wed, Apr 23, 2014 at 10:34 PM, erik quanstrom <quanstro@quanstro.net>
>> wrote:
>> >> >>> #!/bin/rc
>> >> >>> {
>> >> >>>  echo 'echo $SYSNAME!`uname -n`!$USER'
>> >> >>>  echo 'PS1='':; '' PS2='' '''
>> >> >>> } >/dev/$winid/body
>> >> > this is not valid rc.
>> >> >
>> >> > - erik
>> >> >
>> >> If it's not too much trouble, would you mind demonstrating what valid
>> >> rc
>> >> would be for the part of the script in question.
>> >
>> > i'm wrong of course if the shell you're running is bash,
>> > the script itself is reasonable rc.  i was confused by an
>> > rc script emitting bash.
>> >
>> > - erik
>> >
>>
>



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

* Re: [9fans] writing to /dev/$winid/addr
  2014-04-24  4:25               ` Alexander Kapshuk
@ 2014-04-25  6:35                 ` Bence Fábián
  0 siblings, 0 replies; 10+ messages in thread
From: Bence Fábián @ 2014-04-25  6:35 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 1453 bytes --]

to clarify:
it is an rc script, but the echo commands pump commands to a ksh through an
acme win window.
then he collects the output


2014-04-24 6:25 GMT+02:00 Alexander Kapshuk <alexander.kapshuk@gmail.com>:

> I'm sorry I confused you. In my second email I did mention that the
> script was used to set a prompt and an acme window name when running
> win and being logged onto UNIX.
>
>
> On Thu, Apr 24, 2014 at 7:18 AM, Jacob Todd <jaketodd422@gmail.com> wrote:
> > Then why did you say it was rc? What's wrong with you.
> >
> > On Apr 24, 2014 12:18 AM, "Alexander Kapshuk" <
> alexander.kapshuk@gmail.com>
> > wrote:
> >>
> >> That's OK. It's actually ksh on AIX.
> >>
> >> Thanks for your feedback anyway.
> >>
> >>
> >> On Wed, Apr 23, 2014 at 10:34 PM, erik quanstrom <quanstro@quanstro.net
> >
> >> wrote:
> >> >> >>> #!/bin/rc
> >> >> >>> {
> >> >> >>>  echo 'echo $SYSNAME!`uname -n`!$USER'
> >> >> >>>  echo 'PS1='':; '' PS2='' '''
> >> >> >>> } >/dev/$winid/body
> >> >> > this is not valid rc.
> >> >> >
> >> >> > - erik
> >> >> >
> >> >> If it's not too much trouble, would you mind demonstrating what valid
> >> >> rc
> >> >> would be for the part of the script in question.
> >> >
> >> > i'm wrong of course if the shell you're running is bash,
> >> > the script itself is reasonable rc.  i was confused by an
> >> > rc script emitting bash.
> >> >
> >> > - erik
> >> >
> >>
> >
>
>

[-- Attachment #2: Type: text/html, Size: 2460 bytes --]

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

end of thread, other threads:[~2014-04-25  6:35 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-22 13:53 [9fans] writing to /dev/$winid/addr Alexander Kapshuk
2014-04-23  7:29 ` Alexander Kapshuk
2014-04-23 17:03   ` Bence Fábián
2014-04-23 18:07     ` erik quanstrom
2014-04-23 19:13       ` Alexander Kapshuk
2014-04-23 19:34         ` erik quanstrom
2014-04-24  4:15           ` Alexander Kapshuk
2014-04-24  4:18             ` Jacob Todd
2014-04-24  4:25               ` Alexander Kapshuk
2014-04-25  6:35                 ` Bence Fábián

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