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

Expect cleanup routine

36 views
Skip to first unread message

Why Tea

unread,
Apr 4, 2011, 2:49:59 AM4/4/11
to
In Expect, how do you implement a cleanup routine that
always gets called before the script exits. For example,
in the middle of the script if a condition fails, it
can simply exit with an error code and message to be
displayed in the cleanup routine. Of course the cleanup
routine will also perform some cleanup tasks.

Thanks!

/WT

Uwe Klein

unread,
Apr 4, 2011, 3:11:59 AM4/4/11
to
catch possible errors.
A: via adding timeout and eof handler scripts
to your expect patterns.
B. via catch at select places that can have errors.
C: via catch as a global wrapper
D: rename [exit] to _exit and write a new [exit] proc that
does your finalisation stuff and then in a last step
calls [_exit], the original (TM) .

uwe

Matthias Kraft

unread,
Apr 6, 2011, 4:49:36 AM4/6/11
to

Expect has its own [exit] command. It also comes with a flag "-onexit"
which takes its argument and registeres it as exit handler. See man-page of
Expect.

kind regards
--
Matthias Kraft
Software AG, Germany

Why Tea

unread,
Apr 7, 2011, 9:07:51 PM4/7/11
to

Thanks Matthias. That's exactly what I was looking for. Just
noticed that it's explained in Don Libes' book as well.

/WT

0 new messages