[TriLUG] Re: expect problem

Greg Brown gwbrown1 at gmail.com
Wed Sep 21 09:57:32 EDT 2005


You would think so, but apparently not. I found this example on page 482 of
the 1996 edition of exploring Expect:

if [regexp "(\[^:]*:.*\[-, ] (\[0-9]+" $buf dummy ng seen]

Logically you would think that you would have to escape the "]" but you
don't seem to have it as strage as that seems.

Greg

On 9/21/05, David McDowell <turnpike420 at gmail.com> wrote:
>
> if you escape the [ ... wouldn't you need to escape the ] ?
>
>
> On 9/20/05, Greg Brown <gwbrown1 at gmail.com> wrote:
> > Ah! In case anyone else runs into this, it turns out the probelm was the
> > following line:
> >
> > expect "*[y/n]:"
> >
> > I should have seen this the first time, but the problem is the "["
> > character. This is a character that is used in if/then loops (i.e. if ![
> 1 =
> > 2 ] - and I'm not sure if that sytax is correct). Anyway, the fix was to
> put
> > the standard escape character "\" before the "[" and the problem goes
> away.
> > With that in mind the new line is:
> >
> > expect "*\[y/n]:"
> >
> > Volia. Problem solved.
> >
> > Greg
> >
> > On 9/20/05, Greg Brown <gwbrown1 at gmail.com> wrote:
> > >
> > > Hey peeps.. I seem to have a bug in my expect script. The script
> changes
> > > passwords on HP blade servers via telnet. It appears that I am getting
> an
> > > extra line back from the server that I was not, um, expecting and it
> causes
> > > the script to exit. Here is the section of script I am concered with:
> > >
> > > # look for "accepted"
> > > expect "*accepted."
> > >
> > > # now look for <hostname>-User Access Control#
> > > expect "*Control#"
> > >
> > > # send an apply
> > > send "apply\r"
> > >
> > > # look for the same prompt as before
> > > expect "*Control#"
> > >
> > > # now tell it to save
> > > send "save\r"
> > >
> > > # now look for the FLASH prompt
> > > expect "*[y/n]:"
> > >
> > > # enter a "Y"
> > > send "Y\r"
> > >
> > > the script fails after "apply" here is captured output (but
> redirecting
> > > stdout, nothing was ever sent to stderr):
> > >
> > > - User Access Control# usrpw
> > > Changing USER password; validation required:
> > > Enter current administrator password:
> > > Enter new user password:
> > > Re-enter new user password:
> > > New user password accepted.
> > >
> > > >> rtpndsfnth1a8 - User Access Control# apply
> > > ------------------------------------------------------------------
> > > Apply complete; don't forget to "save" updated configuration.
> > >
> > > >> xxxxxxxxxxx - User Access Control# spawn telnet xxx.xxx.xxx.252
> > > Trying xxx.xxx.xxx..252...
> > >
> > >
> > > See, that extra "Apply complete" line seem to be throwing me off. The
> next
> > > line should be the "Control" prompt I am looking for and I thought
> that this
> > > extra line would be processed as I thought it should but it is causing
> the
> > > whole script to fail. The script itself is called via a shell script
> and it
> > > is only invoked one IP at a time (via the parent shell script).
> > >
> > > Any ideas?
> > >
> > > Greg
> > >
> > >
> > --
> > TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> > TriLUG Organizational FAQ : http://trilug.org/faq/
> > TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
> > TriLUG PGP Keyring : http://trilug.org/~chrish/trilug.asc
> >
> --
> TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> TriLUG Organizational FAQ : http://trilug.org/faq/
> TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
> TriLUG PGP Keyring : http://trilug.org/~chrish/trilug.asc
>



More information about the TriLUG mailing list