9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] help, i'm in a wet paper bag and I can't get out
@ 2001-06-12  9:51 rog
  2001-06-12 12:40 ` Boyd Roberts
  2001-06-12 16:26 ` Jonathan Sergent
  0 siblings, 2 replies; 31+ messages in thread
From: rog @ 2001-06-12  9:51 UTC (permalink / raw)
  To: 9fans

sergent@IO.COM wrote:
> {
> 	while () {
> 		line=`{read}
> 		echo line: $line
> 	}
> } < filename

only problem is that's not very efficient, and possibly wrong (for
packet oriented connections, such as UDP), as it can only read one
character at a time...

that buffering problem was the reason i implemented a getlines
primitive in the inferno std module which defines its own loop:

	getlines {
		echo line: $line
	} < filename

still, i'm not sure that shell scripts are the right place to be
implementing network protocols (although i can't say i'm entirely
innocent). dhog made a good suggestion:  that way you can run your
program on any system supported by inferno, which is a nice bonus.

 cheers,
    rog.



^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [9fans] help, i'm in a wet paper bag and I can't get out
@ 2001-06-12 18:21 forsyth
  0 siblings, 0 replies; 31+ messages in thread
From: forsyth @ 2001-06-12 18:21 UTC (permalink / raw)
  To: 9fans

>>you could always say "evil crackers attack vitanuova and steal very useful
>>inferno plugIn for IE" should get you on /. and that usually gets a few
>>converts ;)

i suspect we are more worried about ending up in the computing press
with ``vita nuova provides evil crackers with yet another nasty gateway into ...''.
admittedly a very big software company seems to get away with it,
but i suspect that's because they are very big software company, not
because they really got away with it.

in the interim, we'll probably go with an intermediate scheme that i think
will be adequate and be no more subtle for the user than anything else
on the net (ie, subtle enough but they should know by now).

we already did get a large number of downloads after mention on /.,
so that bit was easy.  ``don't they know how wrong this is?''
was one response.  i sometimes think that about computing.



^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [9fans] help, i'm in a wet paper bag and I can't get out
@ 2001-06-12 17:17 rog
  2001-06-12 23:04 ` rob pike
  0 siblings, 1 reply; 31+ messages in thread
From: rog @ 2001-06-12 17:17 UTC (permalink / raw)
  To: 9fans

> Yes, that was bugging me too.  But what else can you do if you might end
> up in a subprocess?  You end up with magic to seek the file descriptor
> backwards to cover up the fact that you read too much, and turning off
> buffering on file descriptors where seek doesn't work.

in general you can't do it. there's no way of finding out whether seek
works on a file, as it's done at the client end of a 9p or styx
connection (server just sees a read at a particular offset).  the
bourne shell's built-in read was actually just as bad; it just happened
to work most of the time, so you didn't notice.

> > 	getlines {
> > 		echo line: $line
> > 	} < filename
>
> That seems kind of awkward.  You might not want to do your reads in a
> loop; you might want to do them in multiple places; perhaps inside a
> function.

the basic problem is that due to the nature of the shell, the programs
it invokes can't maintain state from invocation to invocation. so
something like the above construct is the only way AFAIK of doing
buffering properly.

if you don't want your reads in a loop, then you have to sacrifice some
buffering. the inferno read(1) is somewhat different from the plan 9
read, and more like the read(2) system call:

	read 200

will make a single 200 byte read request and write the result to
stdout. at least this doesn't have to read a character at a time, but
it's dangerous for non-record-oriented files, as it might split utf
byte sequences.

although the buffered read with implicit loop looks as if it might be
awkward, in practise i haven't found it to be so.  it does seem to be a
very common way of structuring input-reading programs. and in the
inferno shell, you can always use the tk module and its channels to
change the structure around:

	load tk
	chan lines
	getlines {
		send lines $line
	} < /limbo/com.c &
	
	subfn readline {
		result = ${recv lines}
	}
	
	echo first line is: ${readline}
	echo second line is: ${readline}
	echo third line is: ${readline}

whether that's really ugly or quite elegant i'll leave as an exercise
for the reader...



^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [9fans] help, i'm in a wet paper bag and I can't get out
@ 2001-06-12 17:00 forsyth
  2001-06-12 17:02 ` Jonathan Sergent
  0 siblings, 1 reply; 31+ messages in thread
From: forsyth @ 2001-06-12 17:00 UTC (permalink / raw)
  To: 9fans

>>I've done HTTP, FTP, and RTSP in ksh-88... oh, well.

not OSPF?



^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [9fans] help, i'm in a wet paper bag and I can't get out
@ 2001-06-12 14:32 rog
  2001-06-12 14:58 ` Matt
  0 siblings, 1 reply; 31+ messages in thread
From: rog @ 2001-06-12 14:32 UTC (permalink / raw)
  To: 9fans

matt wrote:
> but when can I look forward to signing it and dropping it on a web page and
> using the Limbo plugin for IE ?
>
> that would be pretty useful. Giving clients a url of our IRC server instead
> of saying "download an IRC client".

despite our reticence on the matter, we have been thinking quite hard
about this. the problem is that there are some difficult security
issues that need to be resolved before we do it, none of which have
obvious solutions.

like: what happens if someone puts a limbo app on a web page that takes
up no screen space, but dials out and does nefarious things (e.g.
taking part in a DDOS attack). ok, so if you've got signatures, you
know who purported to sign the app, but what public key infrastructure
do you use? how do you handle key revocation?  i don't think it would
be desirable to produce something as unwieldy (and insecure) as the
stuff used by Windows, but neither does one want to burden the user
more than absolutely necessary.

plus probably a hundred other issues which i've forgotten about for the
moment.

it would be lovely to have limbo applications running inside IE with
access to all available devices (apart from anything, it makes for an
extremely easy-to-install inferno), but until the above problems are
solved, i'm not sure it's a good idea.

  cheers,
    rog.



^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [9fans] help, i'm in a wet paper bag and I can't get out
@ 2001-06-12 13:36 rog
  2001-06-12 13:43 ` Matt
  0 siblings, 1 reply; 31+ messages in thread
From: rog @ 2001-06-12 13:36 UTC (permalink / raw)
  To: 9fans

> One of the problems the monolithic perl script had was that to add
> functionality they had to kill the bot, change the script and then log in
> again.

to bang on (so to speak) about my personal favourite hammer, this is
something that limbo is well suited for, as it provides dynamic loading
& unloading of modules trivially.

	if ((mod := lookupmod(name)) == nil) {
		mod = load IRCbot "/dis/ircbots/" + name;
		if (mod == nil) {
			sys->fprint(stderr, "cannot find module %s: %r\n", name);
			return;
		}
		stashmod(name, mod);
	}
	mod->functionality();



^ permalink raw reply	[flat|nested] 31+ messages in thread
[parent not found: <matt@proweb.co.uk>]

end of thread, other threads:[~2001-06-15 14:25 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-12  9:51 [9fans] help, i'm in a wet paper bag and I can't get out rog
2001-06-12 12:40 ` Boyd Roberts
2001-06-12 13:02   ` Matt
2001-06-12 13:18     ` Boyd Roberts
2001-06-12 13:38       ` Matt
2001-06-12 14:56         ` Boyd Roberts
2001-06-12 14:05     ` Dan Cross
2001-06-12 16:26 ` Jonathan Sergent
2001-06-12 19:33   ` Boyd Roberts
  -- strict thread matches above, loose matches on Subject: below --
2001-06-12 18:21 forsyth
2001-06-12 17:17 rog
2001-06-12 23:04 ` rob pike
2001-06-12 17:00 forsyth
2001-06-12 17:02 ` Jonathan Sergent
2001-06-12 19:38   ` Boyd Roberts
2001-06-12 14:32 rog
2001-06-12 14:58 ` Matt
2001-06-12 18:51   ` Boyd Roberts
2001-06-12 13:36 rog
2001-06-12 13:43 ` Matt
2001-06-12 14:58   ` Boyd Roberts
     [not found] <matt@proweb.co.uk>
2001-06-12  0:39 ` Matt
2001-06-12  0:55   ` Scott Schwartz
2001-06-12  1:12     ` Boyd Roberts
2001-06-12  1:00   ` Boyd Roberts
2001-06-12  1:30     ` Jonathan Sergent
2001-06-15  8:27     ` Hermann Samso
2001-06-15 11:53       ` Boyd Roberts
2001-06-15 12:18         ` Matt
2001-06-15 14:01         ` Matt
2001-06-15 14:25           ` Boyd Roberts

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