From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: To: 9fans@cse.psu.edu Subject: Re: [9fans] ppp patches From: Richard Miller In-Reply-To: <7ce34037c3cbd6915eeb039abcdbd617@plan9.bell-labs.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Date: Mon, 21 Jul 2003 08:48:42 +0100 Topicbox-Message-UUID: fdbc3974-eacb-11e9-9e20-41e7f4b1d025 > Actually, I've been trying to get rid of the cat stuff in favor of the > dial/expect, dial/at stuff. Since this can be embedded in a shell script > with a control structure, I find it a lot more powerful than our chat > scripts. I'ld rather see the effort go there than turning the chat > scripts into another rc. Rc seems to be a perfectly adequate scripting engine. Here's the rough and ready script I used for compuserve. The command 'cread [-t S] C' copies from stdin to stdout until character C is encountered or S seconds elapse. It might be usefully generalised by making C a regular expression, but the simple form was enough for my scripts. (A google gropups search shows that I posted this to comp.os.plan9 on 2000-11-14) #!/bin/rc fn expect { x=`{cread -t $1 :}; echo got: $x >[1=2]; ~ $x *^$2^*} fn send { echo sent: $1 >[1=2]; echo $1 | tr '\12' '\15' } fn sendq { echo $1 | tr '\12' '\15' } fn readuntil { @{ while (x=`{cread -t 60 ' '}) { echo got: $x >[1=2]; if (~ $x *^$1^*) exit () } } } echo $0 running >[1=2] send '' while (! expect 10 ame:) {send ''} send CIS if (! expect 10 ID:) exit 'no ID prompt' send 999999,999/GO:PPPCONNECT expect 60 GO: if (! expect 10 ord:) exit 'no password prompt' sendq '*my*password*' readuntil 'One moment please' -- Richard