9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Richard Miller <miller@hamnavoe.demon.co.uk>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] ppp patches
Date: Mon, 21 Jul 2003 08:48:42 +0100	[thread overview]
Message-ID: <a940177d4dcd828b55621a96fe5dc6ce@hamnavoe.demon.co.uk> (raw)
In-Reply-To: <7ce34037c3cbd6915eeb039abcdbd617@plan9.bell-labs.com>

> 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



  reply	other threads:[~2003-07-21  7:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-20 23:51 Scott Schwartz
2003-07-21  0:48 ` David Presotto
2003-07-21  7:48   ` Richard Miller [this message]
2003-07-21 12:34   ` David Presotto
2003-07-21 14:51     ` Scott Schwartz
2003-07-21 15:08       ` David Presotto
2003-07-23  1:42         ` Scott Schwartz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a940177d4dcd828b55621a96fe5dc6ce@hamnavoe.demon.co.uk \
    --to=miller@hamnavoe.demon.co.uk \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).