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 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-15 14:01         ` Matt
@ 2001-06-15 14:25           ` Boyd Roberts
  0 siblings, 0 replies; 31+ messages in thread
From: Boyd Roberts @ 2001-06-15 14:25 UTC (permalink / raw)
  To: 9fans

> no news is good news?

well, it's better than being the middle of a firefight...
err, flamewar.

> A basic irc bot that evals commands it's given with
> the permission & namespace of whoever started it.
> http://www.proweb.co.uk/~matt/chugly.rc

ok, will do.

i got it down to this as a mashfile:

for (i in contrib/*)
contrib.html : $i/li.html;

*/*/li.html :~ $1/$2/url { mash tools/c2li $1/$2 > $0 };
*/*/url :~ $1/$2/desc {};
*/*/desc :~ $1/$2/from {};
*/*/from :~ $1/$2/date {};

*.html :~ $1/0/url { cat $1/*/li.html > $0 };

default: index.html {};

index.html : head.html contrib.html tail.html { cat head.html contrib.html tail.html > index.html };

----

the contrib directory has directories, named 0...n, which have these files:

     url
     desc [description]
     from
     date [rfc822/std11 date.  it's well known and can be parsed]
     li.html [this is the html <li> made out of the above files]

brucee gave me a bit of a hand, 'cos mash-mk is not mk or make.
i think he has a much better and simpler solution to the problem.




^ 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-15 11:53       ` Boyd Roberts
  2001-06-15 12:18         ` Matt
@ 2001-06-15 14:01         ` Matt
  2001-06-15 14:25           ` Boyd Roberts
  1 sibling, 1 reply; 31+ messages in thread
From: Matt @ 2001-06-15 14:01 UTC (permalink / raw)
  To: 9fans

bugger, sorry


>but about the only thing it's done is to a) proove a
>point and b) receive mail of the form 'nice page.
no news is good news?



>matt's rc irc bot could be added if he so wishes

A basic irc bot that evals commands it's given with
the permission & namespace of whoever started it.
http://www.proweb.co.uk/~matt/chugly.rc





^ 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-15 11:53       ` Boyd Roberts
@ 2001-06-15 12:18         ` Matt
  2001-06-15 14:01         ` Matt
  1 sibling, 0 replies; 31+ messages in thread
From: Matt @ 2001-06-15 12:18 UTC (permalink / raw)
  To: 9fans


----- Original Message ----- 
From: "Boyd Roberts" <boyd@fr.inter.net>
To: <9fans@cse.psu.edu>
Sent: Friday, June 15, 2001 12:53 PM
Subject: Re: [9fans] help, i'm in a wet paper bag and I can't get out


> From: "Hermann Samso" <samso@studserv.stud.uni-hannover.de>
> > With so many snippets of code, everyone could make use
> > of, isn't there any common repository? Or will they
> > allget integrated in time for next release?
> > Ok, there is always Deja News, but...
> 
> oh, but there is.  you must have missed the 'why don't
> we build a common repository' thread.  i finally cracked
> (in desperation) and did this:
> 
>     http://mapage.noos.fr/~repo
> 
> but about the only thing it's done is to a) proove a
> point and b) receive mail of the form 'nice page.
> 
> the first cut was done by hand, the second is automated
> with a mash-mk mashfile on inferno.
> 
> the bitsy code should probably go back to 1127.
> i don't mind adding it too.
> 
> matt's rc irc bot could be added if he so wishes.
> 
> 
> 



^ 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-15  8:27     ` Hermann Samso
@ 2001-06-15 11:53       ` Boyd Roberts
  2001-06-15 12:18         ` Matt
  2001-06-15 14:01         ` Matt
  0 siblings, 2 replies; 31+ messages in thread
From: Boyd Roberts @ 2001-06-15 11:53 UTC (permalink / raw)
  To: 9fans

From: "Hermann Samso" <samso@studserv.stud.uni-hannover.de>
> With so many snippets of code, everyone could make use
> of, isn't there any common repository? Or will they
> allget integrated in time for next release?
> Ok, there is always Deja News, but...

oh, but there is.  you must have missed the 'why don't
we build a common repository' thread.  i finally cracked
(in desperation) and did this:

    http://mapage.noos.fr/~repo

but about the only thing it's done is to a) proove a
point and b) receive mail of the form 'nice page.

the first cut was done by hand, the second is automated
with a mash-mk mashfile on inferno.

the bitsy code should probably go back to 1127.
i don't mind adding it too.

matt's rc irc bot could be added if he so wishes.




^ 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  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
  1 sibling, 1 reply; 31+ messages in thread
From: Hermann Samso @ 2001-06-15  8:27 UTC (permalink / raw)
  To: 9fans

Boyd Roberts <boyd@fr.inter.net> wrote:
>> I got this far but of course (I can say that now) 
>> the `{..} doesn't return until $netdir/data sends an eof
>> and then prints each line

> well, obviously.  it's a file isn't it? <smirk>

>> so how do i read a line at a time before `{..} closes it's stdout?

> write some C program that that reads _unbuffered_ characters
> and spits them until it sees 'end of line' (whatever that may be).
> you should buffer the output, but _not_ the input.

> can't be more than 20 lines of code.

> btw: i hope you're dealing with 8 bit chars 'cos latin-1 will
>      really screw up utf encoded streams that the rest of the
>      system expects.  years ago i wrote (on ultrix) riso [rune
>      to iso-latin-1] and isor (pronounced eye-sore) filters
>      so that the unix sam could deal with the few french docs
>      i had to deal with.

	With so many snippets of code, everyone could make use
	of, isn't there any common repository? Or will they
	allget integrated in time for next release?
	Ok, there is always Deja News, but...

	saludos,
		hermann samso


^ 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, 0 replies; 31+ messages in thread
From: rob pike @ 2001-06-12 23:04 UTC (permalink / raw)
  To: 9fans

You can do something closer to the inferno
    read 200
with something along the lines of
    syscall -o read 0 200 buf >[2] /dev/null

-rob




^ 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:02 ` Jonathan Sergent
@ 2001-06-12 19:38   ` Boyd Roberts
  0 siblings, 0 replies; 31+ messages in thread
From: Boyd Roberts @ 2001-06-12 19:38 UTC (permalink / raw)
  To: 9fans

> I think this is off-topic now.

you can run, but you can't hide.




^ 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 16:26 ` Jonathan Sergent
@ 2001-06-12 19:33   ` Boyd Roberts
  0 siblings, 0 replies; 31+ messages in thread
From: Boyd Roberts @ 2001-06-12 19:33 UTC (permalink / raw)
  To: 9fans

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

that is sick.




^ 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:58 ` Matt
@ 2001-06-12 18:51   ` Boyd Roberts
  0 siblings, 0 replies; 31+ messages in thread
From: Boyd Roberts @ 2001-06-12 18:51 UTC (permalink / raw)
  To: 9fans

> Just giving it access only the domain it came from would suit me.
> 
> esp. if that meant *.domainIcamefrom.com

domains?  well as long as they are derived from local 'secure'
source rather that the DNS you're probably fairly safe.

what rog was talking about seemed to be some PKI based code
signing system.  i think the PKI's unworkable.  i'm not sure
what the solution is, but it would be a lot more secure if
you had the certificate of the signer on a chip card that
you jam into your machine.  gnarly problem, i think.




^ 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
  2001-06-12 19:38   ` Boyd Roberts
  0 siblings, 1 reply; 31+ messages in thread
From: Jonathan Sergent @ 2001-06-12 17:02 UTC (permalink / raw)
  To: 9fans


On Tuesday, June 12, 2001, at 10:00 AM, forsyth@vitanuova.com wrote:

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

I think this is off-topic now.


^ 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  9:51 rog
  2001-06-12 12:40 ` Boyd Roberts
@ 2001-06-12 16:26 ` Jonathan Sergent
  2001-06-12 19:33   ` Boyd Roberts
  1 sibling, 1 reply; 31+ messages in thread
From: Jonathan Sergent @ 2001-06-12 16:26 UTC (permalink / raw)
  To: 9fans


On Tuesday, June 12, 2001, at 02:51 AM, rog@vitanuova.com wrote:

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

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.

> 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

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.

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

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


^ 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
  2001-06-12 18:51   ` Boyd Roberts
  0 siblings, 1 reply; 31+ messages in thread
From: Matt @ 2001-06-12 14:58 UTC (permalink / raw)
  To: 9fans

> 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

I understand the problem.

Shame.
Just giving it access only the domain it came from would suit me.

esp. if that meant *.domainIcamefrom.com

I can just about see http://haxor.aol.com atacking dialup123.aol.com
in that scenario but go-on. I won't tell anyone it was you.

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

M





^ 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:43 ` Matt
@ 2001-06-12 14:58   ` Boyd Roberts
  0 siblings, 0 replies; 31+ messages in thread
From: Boyd Roberts @ 2001-06-12 14:58 UTC (permalink / raw)
  To: 9fans

> project2 will be the Inferno irc client

make sure you read that protocol spec :)




^ 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:38       ` Matt
@ 2001-06-12 14:56         ` Boyd Roberts
  0 siblings, 0 replies; 31+ messages in thread
From: Boyd Roberts @ 2001-06-12 14:56 UTC (permalink / raw)
  To: 9fans

> I was quite enjoying the challenge. 

well as my M-1 Abrams tank commander mate said to me:

    never give up, but choose your battles wisely.




^ 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:02   ` Matt
  2001-06-12 13:18     ` Boyd Roberts
@ 2001-06-12 14:05     ` Dan Cross
  1 sibling, 0 replies; 31+ messages in thread
From: Dan Cross @ 2001-06-12 14:05 UTC (permalink / raw)
  To: 9fans

In article <018001c0f33f$fb7d5c80$6401a8c0@freeze2k> you write:
>Thanks to everyone's suggestions. It's been fun to see everyone's favourite
>hammer
>
>Use python
>Use Limbo
>Use C
>Use awk
>
>just about everything but "Use perl" !

Use COBOL, dude....

	- Dan C.

:-P


^ 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
  2001-06-12 14:58   ` Boyd Roberts
  0 siblings, 1 reply; 31+ messages in thread
From: Matt @ 2001-06-12 13:43 UTC (permalink / raw)
  To: 9fans

okay okay :)

project2 will be the Inferno irc client

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

I might get a gold star for that one.

Matt

/me dreams of weaning clients away from html for administrating their sites
/me doesn't want to hear about java.

----- Original Message -----
From: <rog@vitanuova.com>
To: <9fans@cse.psu.edu>
Sent: Tuesday, June 12, 2001 2:36 PM
Subject: Re: [9fans] help, i'm in a wet paper bag and I can't get out


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

* Re: [9fans] help, i'm in a wet paper bag and I can't get out
  2001-06-12 13:18     ` Boyd Roberts
@ 2001-06-12 13:38       ` Matt
  2001-06-12 14:56         ` Boyd Roberts
  0 siblings, 1 reply; 31+ messages in thread
From: Matt @ 2001-06-12 13:38 UTC (permalink / raw)
  To: 9fans

ok i lied about the last post thing 

----- Original Message ----- 
From: "Boyd Roberts" <boyd@fr.inter.net>
To: <9fans@cse.psu.edu>
Sent: Tuesday, June 12, 2001 2:18 PM
Subject: Re: [9fans] help, i'm in a wet paper bag and I can't get out


> > I actually started the ircbot as a way to get to grips with plan9 c.
> 
> ouch.  string handling in C -- no thanks.  limbo is a total win,

I was quite enjoying the challenge. 
The next stage was to make a hash table of Commands to function pointers.
so I could lose the if {strcmp} else if {strcmp} that was going to expand.
For a minute it was like being back in the Windows 3.1 API.


main(void) {
 int fd;
 int state = 0;
 Biobuf bio;
 String *line = s_new();
 String *token = s_new();

 int i = 0;

 fd = dial("tcp!irc!6667",0 , 0, 0);
 if (fd < 0)
  return;

 Binit(&bio, fd, OREAD);
  
 while(s_getline(&bio, s_restart(line))) {
  s_restart(line);
  print ("%s\n", s_to_c(line));
  s_parse(line, s_restart(token));
  if(strcmp("PING", s_to_c(token)) == 0) {
   s_parse(line, s_restart(token));
   fprint(fd, "PONG %s\n", s_to_c(token));
   if (state == 0) {
    fprint(fd, "JOIN #chan\nPRIVMSG #chan hullo\n");
    state = 1;
   }
  } 
   
  if(i++ == 2) {
   fprint(fd, "USER bot cb.com ircserver ChuglyV0.1\nNICK Chugly\n"); 
  }
 }
}




^ 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

* Re: [9fans] help, i'm in a wet paper bag and I can't get out
  2001-06-12 13:02   ` Matt
@ 2001-06-12 13:18     ` Boyd Roberts
  2001-06-12 13:38       ` Matt
  2001-06-12 14:05     ` Dan Cross
  1 sibling, 1 reply; 31+ messages in thread
From: Boyd Roberts @ 2001-06-12 13:18 UTC (permalink / raw)
  To: 9fans

> I actually started the ircbot as a way to get to grips with plan9 c.

ouch.  string handling in C -- no thanks.  limbo is a total win,
just on this one point.  but there's a lot more to limbo than
just that.  i really like limbo.




^ 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 12:40 ` Boyd Roberts
@ 2001-06-12 13:02   ` Matt
  2001-06-12 13:18     ` Boyd Roberts
  2001-06-12 14:05     ` Dan Cross
  0 siblings, 2 replies; 31+ messages in thread
From: Matt @ 2001-06-12 13:02 UTC (permalink / raw)
  To: 9fans

I actually started the ircbot as a way to get to grips with plan9 c.

the first one logged in and then spat out the IRC lines on stdout for me to
see what was going on.

My spawning it with & and doing
echo 'PRIVMSG #chann :msg' > /net/tcp/N/data

gave me a fully blown client ! which wasn't bad for 10 lines of C I thought.

and it (false) dawned on me that maybe that was all the C I had to write.

And then after scratching a bit deeper I understood Russ's rlogin script a
bit better and saw that I didn't even need my C to do the connection (and
that's where I fell into the paper bag).

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.

I thought I was able to leverage the namespace feature as a process jail so
I could sandbox the evals. In this was to add new commands to the bot all I
had to do was add new things to it's namespace. That has been the most
disappointing aspect as so much of the checking I've got to do now would
have fallen out of having that sandbox. Oh well. I can understand why.

Thanks to everyone's suggestions. It's been fun to see everyone's favourite
hammer

Use python
Use Limbo
Use C
Use awk

just about everything but "Use perl" !

I've got everything I need to make it work now I think.
Next post from me about it should be the working code.

Matt




^ 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  9:51 rog
@ 2001-06-12 12:40 ` Boyd Roberts
  2001-06-12 13:02   ` Matt
  2001-06-12 16:26 ` Jonathan Sergent
  1 sibling, 1 reply; 31+ messages in thread
From: Boyd Roberts @ 2001-06-12 12:40 UTC (permalink / raw)
  To: 9fans

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

neither am i.  for the current irc thing i think limbo would be a
more efficient and more secure choice.  that damn irc protocol seems
to be in rfc limbo (no pun intended).  i wouldn't like some piece
of unforseen braindamage to break your script.

rc is a lot more bulletproof than the shell, but scripts executing
stuff that 3rd parties hand up is fraught with peril; you just don't
have the conscise, fine grained analysis that limbo gives you.

you could probably do it with rc, but it would be large chunks
of code to do the string mangling/validation and that leaves you
open to screwups.

1000 line scripts are not your friends.




^ 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  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  1:00   ` Boyd Roberts
@ 2001-06-12  1:30     ` Jonathan Sergent
  2001-06-15  8:27     ` Hermann Samso
  1 sibling, 0 replies; 31+ messages in thread
From: Jonathan Sergent @ 2001-06-12  1:30 UTC (permalink / raw)
  To: 9fans


On Monday, June 11, 2001, at 06:00 PM, Boyd Roberts wrote:

> write some C program that that reads _unbuffered_ characters
> and spits them until it sees 'end of line' (whatever that may be).
> you should buffer the output, but _not_ the input.

You could just read the manual and use /bin/read, instead of rewriting 
it.

So you get

{
	while () {
		line=`{read}
		echo line: $line
	}
} < filename

Somehow putting the < filename after the inner } makes rc reopen it for 
each loop iteration.  (Am I misinterpreting this?)

A more convoluted way to do to the same thing would be

{ echo 0 > /srv/something.$pid } < filename
while () {
	line=`{read /srv/something.$pid}
	echo line: $line
}
rm /srv/something.$pid

but that's probably better for showing off /srv to your friends than it 
is for actually solving the problem.


^ 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  0:55   ` Scott Schwartz
@ 2001-06-12  1:12     ` Boyd Roberts
  0 siblings, 0 replies; 31+ messages in thread
From: Boyd Roberts @ 2001-06-12  1:12 UTC (permalink / raw)
  To: 9fans

> Instead of "for cat", don't you want "while read"?

well he does, but rc doesn't have 'read'.




^ 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  0:39 ` Matt
  2001-06-12  0:55   ` Scott Schwartz
@ 2001-06-12  1:00   ` Boyd Roberts
  2001-06-12  1:30     ` Jonathan Sergent
  2001-06-15  8:27     ` Hermann Samso
  1 sibling, 2 replies; 31+ messages in thread
From: Boyd Roberts @ 2001-06-12  1:00 UTC (permalink / raw)
  To: 9fans

> I got this far but of course (I can say that now) 
> the `{..} doesn't return until $netdir/data sends an eof
> and then prints each line

well, obviously.  it's a file isn't it? <smirk>

> so how do i read a line at a time before `{..} closes it's stdout?

write some C program that that reads _unbuffered_ characters
and spits them until it sees 'end of line' (whatever that may be).
you should buffer the output, but _not_ the input.

can't be more than 20 lines of code.

btw: i hope you're dealing with 8 bit chars 'cos latin-1 will
     really screw up utf encoded streams that the rest of the
     system expects.  years ago i wrote (on ultrix) riso [rune
     to iso-latin-1] and isor (pronounced eye-sore) filters
     so that the unix sam could deal with the few french docs
     i had to deal with.




^ 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  0:39 ` Matt
@ 2001-06-12  0:55   ` Scott Schwartz
  2001-06-12  1:12     ` Boyd Roberts
  2001-06-12  1:00   ` Boyd Roberts
  1 sibling, 1 reply; 31+ messages in thread
From: Scott Schwartz @ 2001-06-12  0:55 UTC (permalink / raw)
  To: 9fans

| I got this far but of course (I can say that now) 
| the `{..} doesn't return until $netdir/data sends an eof
| and then prints each line

Instead of "for cat", don't you want "while read"?


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

* [9fans] help, i'm in a wet paper bag and I can't get out
@ 2001-06-12  0:39 ` Matt
  2001-06-12  0:55   ` Scott Schwartz
  2001-06-12  1:00   ` Boyd Roberts
  0 siblings, 2 replies; 31+ messages in thread
From: Matt @ 2001-06-12  0:39 UTC (permalink / raw)
  To: 9fans

Well it's not going too well.

I got this far but of course (I can say that now) 
the `{..} doesn't return until $netdir/data sends an eof
and then prints each line

ifs='
'
for (k in `{ cat $netdir/data }) {
    echo $k 
} 


so how do i read a line at a time before `{..} closes it's stdout?

once I've cracked that it's just about finished

M



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

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 18:21 [9fans] help, i'm in a wet paper bag and I can't get out forsyth
  -- strict thread matches above, loose matches on Subject: below --
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
2001-06-12  9:51 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
     [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).