Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

expect emulator?

33 views
Skip to first unread message

James

unread,
Sep 6, 2017, 5:43:05 PM9/6/17
to
Are there expect emulators written in bash or perl?
That would be useful since not all has expect.

TIA
James

Kenny McCormack

unread,
Sep 6, 2017, 8:47:22 PM9/6/17
to
In article <8d6a9749-7f5d-40c5...@googlegroups.com>,
James <hsle...@yahoo.com> wrote:
>Are there expect emulators written in bash or perl?
>That would be useful since not all has expect.

I think the shell command you are looking for is:

# apt-get install expect

--
Atheism:
It's like being the only sober person in the car, and nobody will let you drive.

Randal L. Schwartz

unread,
Sep 6, 2017, 9:03:37 PM9/6/17
to
>>>>> "James" == James <hsle...@yahoo.com> writes:

James> Are there expect emulators written in bash or perl?
James> That would be useful since not all has expect.

https://metacpan.org/pod/Expect

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<mer...@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix consulting, Technical writing, Comedy, etc. etc.
Still trying to think of something clever for the fourth line of this .sig

James

unread,
Sep 7, 2017, 5:07:09 PM9/7/17
to
Was this Expect module written in perl only without taking advantage of the expect library?

Ian Zimmerman

unread,
Sep 8, 2017, 11:55:36 AM9/8/17
to
On 2017-09-06 17:55, Randal L. Schwartz wrote:

>> Are there expect emulators written in bash or perl?
>> That would be useful since not all has expect.
>
> https://metacpan.org/pod/Expect

It should be noted that none of the expect-like libraries for other
languages (perl, python etc.) have the _full_ functionality of the
original, in particular none have the multi-clause interact operation.

This is not an accidental omission; it is because the functionality
depends on a feature in the Tcl custom regexp matcher that other
language runtimes lack (let alone the generic POSIX regexp matcher).

Of course this is very unfortunate because if one needs this
functionality one is stuck with Tcl, not the favorite language of many.

--
Please don't Cc: me privately on mailing lists and Usenet,
if you also post the followup to the list or newsgroup.
Do obvious transformation on domain to reply privately _only_ on Usenet.

Randal L. Schwartz

unread,
Sep 10, 2017, 7:23:20 PM9/10/17
to
>>>>> "James" == James <hsle...@yahoo.com> writes:

James> Was this Expect module written in perl only without taking
James> advantage of the expect library?

Exactly!

Randal L. Schwartz

unread,
Sep 10, 2017, 7:23:20 PM9/10/17
to
>>>>> "Ian" == Ian Zimmerman <i...@primate.usenet-nospam-remove.net> writes:

Ian> On 2017-09-06 17:55, Randal L. Schwartz wrote:
>>> Are there expect emulators written in bash or perl?
>>> That would be useful since not all has expect.
>>
>> https://metacpan.org/pod/Expect

Ian> It should be noted that none of the expect-like libraries for other
Ian> languages (perl, python etc.) have the _full_ functionality of the
Ian> original, in particular none have the multi-clause interact
Ian> operation.

You are misinformed:

https://metacpan.org/pod/Expect#$object->expect($timeout,-@match_patterns)

This is precisely emulating what is available in TCL Expect.

Ian Zimmerman

unread,
Sep 11, 2017, 11:20:27 AM9/11/17
to
On 2017-09-10 16:08, Randal L. Schwartz wrote:

> https://metacpan.org/pod/Expect#$object->expect($timeout,-@match_patterns)
>
> This is precisely emulating what is available in TCL Expect.

No, it is not, just as in the original Expect the full functionality
of "interact" cannot be emulated by a series of "expect" statements.

The crucial (if perhaps subtle) difference is seen when the string in
the input buffer matches one pattern exactly, _and_ is a prefix of a
string that matches another pattern. The original "interact" will
collect enough input to decide between the two. This depends on a
"partial match" function which seems to have been added to the Tcl
regexp API specially for Expect, and as far as I know is unique to it,
maybe with one exception as noted below.

I know this because, long ago, I tried to write an expect-like library
for ocaml, and I had to request the addition of the analogous API point
to the ocaml str library. I no longer remember if that request was
successful.
0 new messages