Blame FAQ

Packit a69f91
Expect FAQ (Frequently Asked Questions)
Packit a69f91
Packit a69f91
An HTML version of this FAQ can be found in http://expect.nist.gov/FAQ.html
Packit a69f91
Packit a69f91
This FAQ lists common questions, usually about subjects that didn't
Packit a69f91
fit well in the book for one reason or another (or weren't
Packit a69f91
indexed sufficiently well so that people can't find the answers easily
Packit a69f91
enough).  In some cases, I've left the original questions.  I suppose
Packit a69f91
I could've stripped off the headers, but it seems more realistic to
Packit a69f91
see actual people who've asked the questions.  Thanks to everyone who
Packit a69f91
asked.
Packit a69f91
Packit a69f91
The man page and the papers listed in the README file should
Packit a69f91
also be consulted for highly technical or philosophical discussion of
Packit a69f91
the implementation, design, and practical application of Expect.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
		Here is the list of questions.  You can search for the corresponding
Packit a69f91
		answer by searching for the question number.  For example searching
Packit a69f91
		for "#3." will get you that answer.
Packit a69f91
Packit a69f91
Packit a69f91
**** General **** 
Packit a69f91
Packit a69f91
#1. I keep hearing about Expect.  So what is it?
Packit a69f91
#2. How do you pronounce "Ousterhout" anyway?  (Or "Libes" for that matter?)
Packit a69f91
Packit a69f91
#3. Why should I learn yet another language (Tcl) instead of
Packit a69f91
writing my interaction in ?
Packit a69f91
#4. What about Perl?
Packit a69f91
#5. Do we need to pay or ask for permission to distribute Expect?
Packit a69f91
#6. Since Expect is free, can we give you a gift?
Packit a69f91
#7. Are there any hidden dangers in using Expect?
Packit a69f91
Packit a69f91
**** Book, newsgroup, FAQ, README, ... **** 
Packit a69f91
Packit a69f91
#8. Why is this FAQ so short?
Packit a69f91
#9. How was this FAQ created?
Packit a69f91
#10. The background makes the FAQ hard to read.
Packit a69f91
#11. Why isn't there an Expect mailing list?
Packit a69f91
#12. Why isn't overlay covered in Exploring Expect?
Packit a69f91
#13. Is the front cover of your book a self portrait (ha ha)?
Packit a69f91
#14. Why don't the examples in your USENIX papers work?
Packit a69f91
#15. Can you put the examples in your book into an anonymous ftp site?
Packit a69f91
#16. Do you have ideas for more articles on Expect?
Packit a69f91
Packit a69f91
**** Can Expect do this? **** 
Packit a69f91
Packit a69f91
#17. Can Expect automatically generate a script from watching a session?
Packit a69f91
#18. Can Expect understand screen-oriented (Curses) programs?
Packit a69f91
#19. Can Expect be run as a CGI script?
Packit a69f91
#20. Can Expect act like a browser and retrieve pages or talk to a CGI script?
Packit a69f91
#21. Can Expect be run from cron?
Packit a69f91
#22. Why does my Expect script not work under inetd?
Packit a69f91
Packit a69f91
**** Compilation or porting questions **** 
Packit a69f91
Packit a69f91
#23. Why can't I compile Expect with Tcl 8.0?
Packit a69f91
#24. Does Expect 5.26 work with Tcl/Tk 8.0.3?
Packit a69f91
#25. Why can't I compile Expect with Tcl/Tk 8.1aX?
Packit a69f91
#26. Why can't I compile Expect with Tcl/Tk 8.0b1?
Packit a69f91
#27. Why does Expect need to be setuid root on Cray?
Packit a69f91
#28. Does Expect run on VMS?
Packit a69f91
#29. Is it possible to use Expect and TclX together?
Packit a69f91
#30. Is it possible to use Expect and <lots of random extensions> together?
Packit a69f91
#31. Why does configure complain about "cross-compiling"?
Packit a69f91
#32. Why are make/configure looping endlessly?
Packit a69f91
#33. Why does compile fail with: Don't know how to make pty_.c?
Packit a69f91
#34. Does Expect run on MSDOS, Win95, WinNT, MacOS, etc...?
Packit a69f91
#35. Why does Expect dump core?  Why can I run Expect as root but not as myself?
Packit a69f91
Packit a69f91
**** Other... **** 
Packit a69f91
Packit a69f91
#36. Is it possible to prevent Expect from printing out its interactions?
Packit a69f91
#37. Why does it send back the same string twice?
Packit a69f91
#38. Why can't I send the line "user@hostname\r"?
Packit a69f91
#39. How do I hide the output of the send command?
Packit a69f91
#40. Why don't I see pauses between characters sent with send -s?
Packit a69f91
#41. Why does "talk" fail with "Who are you?  You have no entry utmp" or
Packit a69f91
	"You don't exist.  Go away"?
Packit a69f91
#42. Why does . match a newline?
Packit a69f91
#43. Why doesn't Expect kill telnet (or other programs) sometimes?
Packit a69f91
#44. How come I get "ioctl(set): Inappropriate ..., bye recursed"?
Packit a69f91
#45. How come there's no interact function in the Expect library?
Packit a69f91
#46. Can't you make tkterm understand any terminal type?
Packit a69f91
#47. Trapping SIGCHLD causes looping sometimes
Packit a69f91
#48. Why do I get "invalid spawn id"?
Packit a69f91
#49. Could you put a version number in the filename of the Expect archive?
Packit a69f91
#50. Why does Expect work as root, but say "out of ptys" when run as myself?
Packit a69f91
#51. Why does spawn fail with "sync byte ...."?
Packit a69f91
#52. Why does Expect fail on RedHat 5.0?
Packit a69f91
#53. Why does Expect fail on RedHat 5.1?
Packit a69f91
#54. Is Expect Y2K compliant?
Packit a69f91
Packit a69f91
Packit a69f91
*
Packit a69f91
* Questions and Answers
Packit a69f91
*
Packit a69f91
Packit a69f91
Packit a69f91
Packit a69f91
**** General **** 
Packit a69f91
Packit a69f91
Packit a69f91
#1. I keep hearing about Expect.  So what is it?
Packit a69f91
Packit a69f91
From: libes (Don Libes)
Packit a69f91
To: Charles Hymes <chymes@crew.umich.edu>
Packit a69f91
Subject: I keep hearing about Expect.  So what is it?
Packit a69f91
Packit a69f91
Charles Hymes writes:
Packit a69f91
>
Packit a69f91
>So, what is Expect?
Packit a69f91
Packit a69f91
Expect is a tool primarily for automating interactive applications
Packit a69f91
such as telnet, ftp, passwd, fsck, rlogin, tip, etc.  Expect really
Packit a69f91
makes this stuff trivial.  Expect is also useful for testing these
Packit a69f91
same applications.  Expect is described in many books, articles,
Packit a69f91
papers, and FAQs.  There is an entire book on it available from
Packit a69f91
O'Reilly.
Packit a69f91
Packit a69f91
Expect is free and in the public domain.  Download instructions can
Packit a69f91
be found in the Expect homepage.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#2. How do you pronounce "Ousterhout" anyway?  (Or "Libes" for that matter?)
Packit a69f91
Packit a69f91
Packit a69f91
From: ouster@sprite.Berkeley.EDU (John Ousterhout)
Packit a69f91
To: libes@cme.nist.gov
Packit a69f91
Subject: Re: pronunciation?
Packit a69f91
Date: Tue, 29 May 90 21:26:10 PDT
Packit a69f91
Packit a69f91
Those of us in the family pronounce it "OH-stir-howt", where the
Packit a69f91
first syllable rhymes with "low", the second with "purr", and the
Packit a69f91
third with "doubt".  Unfortunately this isn't the correct Dutch
Packit a69f91
pronounciation for a name spelled this way (someplace along
Packit a69f91
the line it got misspelled:  it was originally "Oosterhout"), nor
Packit a69f91
is it what you'd guess if you use common sense.  So, we've gotten
Packit a69f91
used to responding to almost anything.
Packit a69f91
Packit a69f91
					-John-
Packit a69f91
Packit a69f91
I suppose I should say something in kind.  "Libes" is pronounced
Packit a69f91
"Lee-bis" with stress on the first syllable.  Like John though, I've
Packit a69f91
gotten used to responding to anything close.
Packit a69f91
Packit a69f91
By the way, notice the date on this message.  I had only written
Packit a69f91
the first cut of Expect four months earlier.  I asked John how to
Packit a69f91
pronounce his name because I had already got a paper accepted into
Packit a69f91
USENIX and needed to be able to say his name correctly while giving
Packit a69f91
the talk!
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#3. Why should I learn yet another language (Tcl) instead of
Packit a69f91
writing my interaction in ?
Packit a69f91
Packit a69f91
From: libes (Don Libes)
Packit a69f91
Subject: Re: Expect, Tcl, programmed dialogue etc.
Packit a69f91
Date: Mon, 2 Sep 91 15:47:14 EDT
Packit a69f91
Packit a69f91
>>>A friend told me about "Expect". But then, I have to know the
Packit a69f91
>>>idiocies of "tcl". I would like to know if there is an alternative
Packit a69f91
>>>to Expect that is also useful in other places, so that I do not
Packit a69f91
>>>have to spend time getting used to tcl for just this one tool.
Packit a69f91
>
Packit a69f91
>>Your reasoning is shortsighted.  Tcl is a language that can be used in
Packit a69f91
>>other applications.  It won't be a waste of your time to learn it.
Packit a69f91
>
Packit a69f91
>I have nothing against tcl as such.
Packit a69f91
>The reluctance to learn it comes mainly from the feeling that half my
Packit a69f91
>life seems to be spent learning new languages that differ very little
Packit a69f91
>from existing ones, and differ in annoying little details at that.
Packit a69f91
>To add to the misery, every implementation has its own
Packit a69f91
>idiosyncracies...:-(
Packit a69f91
Packit a69f91
Ironically, Tcl was written specifically to halt this very problem.
Packit a69f91
Packit a69f91
The author recognized that every utility seems to have its own
Packit a69f91
idiosyncratic .rc file or programming language.  Tcl was designed as a
Packit a69f91
general-purpose language that could be included with any utility, to
Packit a69f91
avoid having everyone hack up their own new language.
Packit a69f91
Packit a69f91
 In this context, your statements do Tcl a great disservice.  
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#4. What about Perl?
Packit a69f91
Packit a69f91
From: libes (Don Libes)
Packit a69f91
To: Joe McGuckin <joe@ns.via.net>
Packit a69f91
Subject: Re: Need Perl examples
Packit a69f91
Date: Sun, 22 Jan 95 20:17:39 EST
Packit a69f91
Packit a69f91
Joe McGuckin writes:
Packit a69f91
>
Packit a69f91
>Yeah, I've scanned through your book a couple of times in the last
Packit a69f91
>week, trying to make up my mind if I should buy it.
Packit a69f91
Packit a69f91
I spent three years writing it - so I'm glad to hear you're spending a
Packit a69f91
little time considering its merit!
Packit a69f91
Packit a69f91
>Pro:
Packit a69f91
>   Looks like implementing some sort of telnet daemon would be trivial.
Packit a69f91
Packit a69f91
Once you see it as an Expect script, you'll realize how trivial
Packit a69f91
these things can really be.
Packit a69f91
Packit a69f91
>Con:
Packit a69f91
>   Yet another language to learn. I know perl reasonably well & would
Packit a69f91
>   like to stick with it.
Packit a69f91
Packit a69f91
Good point.  While I'm not a Perl guru, I've used it quite a bit
Packit a69f91
and it's nice for many things.  But I wouldn't have bothered writing
Packit a69f91
Expect in the first place if I thought Perl was ideal.  And many Perl
Packit a69f91
experts agree - I know a lot of them who call out to Expect scripts
Packit a69f91
rather than do this stuff in Perl - it's that much easier with Expect.
Packit a69f91
Expect is also much more mature.  It's portable, stable, robust, and
Packit a69f91
it's fully documented - with lots of examples and a complete tutorial,
Packit a69f91
too.
Packit a69f91
Packit a69f91
In response to someone complaining about how difficult it was to do
Packit a69f91
something in Perl, Larry Wall once remarked: "The key to using
Packit a69f91
Perl is to focus on its strengths and avoid its weaknesses."  That
Packit a69f91
definitely applies here.
Packit a69f91
Packit a69f91
Even if you do proceed with Perl, you will find the book
Packit a69f91
helpful.  Automating interactive applications has unique pitfalls to
Packit a69f91
it and many of the descriptions and solutions in the book transcend
Packit a69f91
the choice of language that you use to implement them.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#5. Do we need to pay or ask for permission to distribute Expect?
Packit a69f91
Packit a69f91
From: libes (Don Libes)
Packit a69f91
To: Mohammad Reza Jahanbin <mrj@CIS.Prime.COM>
Packit a69f91
Subject: Copyright Question.
Packit a69f91
Date: Tue, 26 Jan 93 23:46:24 EST
Packit a69f91
Packit a69f91
Mohammad Reza Jahanbin writes:
Packit a69f91
>Before anything let me thank you on behalf of ComputeVision R&D for
Packit a69f91
>putting so much effort into Expect. Part of CV has been using Expect
Packit a69f91
>for the past two years or so to build variety of tools including an
Packit a69f91
>automated testbed for a product.
Packit a69f91
>
Packit a69f91
>CV is currently considering shipping the automated testbed to some of its
Packit a69f91
>retailers, to enable them to perform their own tests before distributing
Packit a69f91
>the product.
Packit a69f91
>
Packit a69f91
>The Question is, are we allowed to ship Expect? Do we need to ask
Packit a69f91
>anyone for permission? Do we need to say or write anything in the
Packit a69f91
>documentation? Do we need to pay for it?
Packit a69f91
>
Packit a69f91
>I have not been able to find any copyright (or indeed copyleft) notices
Packit a69f91
>in the usual Expect distribution. Would you be able to clarify our position.
Packit a69f91
Packit a69f91
It is my understanding that you are allowed to do just about anything
Packit a69f91
with Expect.  You can even sell it.  You need not ask our permission.
Packit a69f91
You need not pay for it.  (Your tax dollars, in effect, already have
Packit a69f91
paid for it.)
Packit a69f91
Packit a69f91
You should not claim that you wrote it (since this would be a lie), nor
Packit a69f91
should you attempt to copyright it (this would be fruitless as it is a
Packit a69f91
work of the US government and therefore not subject to copyright).
Packit a69f91
Packit a69f91
NIST would appreciate any credit you can give for this work.  One line
Packit a69f91
may suffice (as far as I'm concerned) although there should be
Packit a69f91
something to the effect that this software was produced for research
Packit a69f91
purposes.  No warantee, guarantee, or liability is implied.
Packit a69f91
Packit a69f91
My management is always interested in feedback on our work.  If you
Packit a69f91
would like to send letters of praise describing how Expect has helped
Packit a69f91
your business, we would be delighted.  Letters (on letterhead please)
Packit a69f91
are strong evidence used by policy makers when deciding where every
Packit a69f91
dollar goes.  If you want to send these letters to NIST directly, you
Packit a69f91
may send them to the following individuals:
Packit a69f91
Packit a69f91
Robert Hebner, Director
Packit a69f91
NIST
Packit a69f91
Admin Bldg, Rm A-1134
Packit a69f91
Gaithersburg, MD 20899
Packit a69f91
Packit a69f91
Ric Jackson, Manufacturing Engineering Laboratory
Packit a69f91
NIST
Packit a69f91
Bldg 220, Rm B-322
Packit a69f91
Gaithersburg, MD 20899
Packit a69f91
Packit a69f91
Steve Ray, Manufacturing Systems Integration Division
Packit a69f91
NIST
Packit a69f91
Bldg 220, Rm A-127
Packit a69f91
Gaithersburg, MD 20899
Packit a69f91
Packit a69f91
Amy Knutilla, Manufacturing Collaboration Technologies Group
Packit a69f91
NIST
Packit a69f91
Bldg 220, Rm A-127
Packit a69f91
Gaithersburg, MD 20899
Packit a69f91
Packit a69f91
In case you're wondering about the uninformative titles, Robert Hebner
Packit a69f91
is the director of all of NIST (about 3000 people) and
Packit a69f91
Amy Knutilla (way down there at the bottom) is my immediate supervisor.
Packit a69f91
Packit a69f91
I hope this has answered your questions.  Let me know if you have
Packit a69f91
further questions.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#6. Since Expect is free, can we give you a gift?
Packit a69f91
Packit a69f91
This is not an actual letter but represents the gist of several
Packit a69f91
that I've received.
Packit a69f91
Packit a69f91
>>>Expect has saved us many thousands of dollars.  We'd like to send
Packit a69f91
>>>you a free copy of our product.
Packit a69f91
>>
Packit a69f91
>>Thanks, but please don't.  As a federal employee, I'm not
Packit a69f91
>>allowed to accept gifts of any significant value.
Packit a69f91
>
Packit a69f91
>But, what if it is for personal use (like at home)? I assume
Packit a69f91
>that would be okay.
Packit a69f91
Packit a69f91
It doesn't matter (much).  What the rules address is whether a gift
Packit a69f91
might cause me to make an official decision differently.  This is
Packit a69f91
especially a concern because I may very well have to decide whether or
Packit a69f91
not to buy products from your company in the future.
Packit a69f91
Packit a69f91
There is a clause that says "you may accept gifts from friends,
Packit a69f91
regardless of value ... but you should be careful to avoid accepting
Packit a69f91
gifts which may create an appearance of impropriety, even if permitted
Packit a69f91
as an exception to the gift rules."
Packit a69f91
Packit a69f91
I'm still permitted to accept small token gifts, such as a t-shirt
Packit a69f91
or reasonably-priced dinner (under $20 per gift to a maximum of $50
Packit a69f91
per year from any person or company) - so things are not totally
Packit a69f91
ridiculous.  Although the precise values in the gift rules seem rather
Packit a69f91
arbitrary, I actually like the gift rules.  They stop a lot of the
Packit a69f91
nonsense that used to go on involving gifts.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#7. Are there any hidden dangers in using Expect?
Packit a69f91
Packit a69f91
From: Charlton Henry Harrison <charlton@cs.utexas.edu>
Packit a69f91
To: libes@NIST.GOV
Packit a69f91
Date: Fri, 27 Jan 1995 23:30:56 -0600
Packit a69f91
Packit a69f91
>>>Dear Don:
Packit a69f91
>>>
Packit a69f91
>>>	I've been a fan of Expect ever since I first learned of UNIX back
Packit a69f91
>>>in late '93. I'm young and don't have my CS degree just yet, but I worked
Packit a69f91
>>>a while back at Texas Instruments in their Telecom Customer Support dept.
Packit a69f91
>>>I started in late '93 (and hence, that's where I first started exploring
Packit a69f91
>>>the UNIX environment) and immediately forsaw the need of automating a lot
Packit a69f91
>>>of my redundant and mindless duties, but I didn't know how since we were
Packit a69f91
>>>working over a heterogeneous LAN with multiple OSs.
Packit a69f91
>>>	Then I found out about Expect. I automated everything! My boss didn't
Packit a69f91
>>>like hearing that I was working on something else in order to get out of
Packit a69f91
>>>work, and I got tired of explaining it to him.
Packit a69f91
>>>	Although I accomplished all the aspects of my duties, I was infamous
Packit a69f91
>>>for being the laziest person at work, and it showed (I made my job SO easy).
Packit a69f91
>>>I got a new boss after a while, and he hated me from the start and fired
Packit a69f91
>>>me soon after. Oh well, I guess my mentality didn't click with theirs. 
Packit a69f91
>>>	There are a lot of people like that: they believe life is putting
Packit a69f91
>>>in a hard day's work to get by. I hate that.
Packit a69f91
>>>	So the point is, thank you for the wonderful 'Expect'. I bought
Packit a69f91
>>>your book and now I have the most recent version of it on my Linux system
Packit a69f91
>>>at home. Needless to say I'm looking for another job, though.
Packit a69f91
>>>
Packit a69f91
>>>							Charlton
Packit a69f91
>>> 
Packit a69f91
>> Thanks very much for your nice letter.  Sorry to hear about your
Packit a69f91
>> automating yourself out of a job.  Actually, I think most computer
Packit a69f91
>> scientists have to face this dilemma.  In some ways, it's a
Packit a69f91
>> self-defeating occupation.
Packit a69f91
>>
Packit a69f91
>> Don
Packit a69f91
>
Packit a69f91
>Yeah, I'd be interested in hearing if you have a personal philosophy on
Packit a69f91
>how to handle this kind of thing. I plan on pursuing a career in Artificial
Packit a69f91
>Intelligence for similar reason of making life easier for everyone (me
Packit a69f91
>in particular!)  What the future holds in this category is a great
Packit a69f91
>mystery.
Packit a69f91
Packit a69f91
I'm glad you asked.  My personal philosophy on this kind of thing is:
Packit a69f91
Find someone really rich and marry them.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
**** Book, newsgroup, FAQ, README, ... **** 
Packit a69f91
Packit a69f91
Packit a69f91
#8. Why is this FAQ so short?
Packit a69f91
Packit a69f91
From: libes (Don Libes)
Packit a69f91
To: Wade Holst <wade@cs.ualberta.ca>
Packit a69f91
Subject: Expect question
Packit a69f91
Packit a69f91
Wade Holst writes:
Packit a69f91
>
Packit a69f91
> 1) Is there a more up-to-date version of the FAQ than what
Packit a69f91
>    comes with expect-5.5?  (For such a useful application, I
Packit a69f91
>    would expect more than 12 questions).
Packit a69f91
Packit a69f91
I know that a lot of other packages have *huge* FAQs but I
Packit a69f91
have always believed that this is an indication that their regular
Packit a69f91
documentation sucks.  As questions arise that are not addressed well
Packit a69f91
by the original docs, the docs themselves should be fixed rather than
Packit a69f91
new ones created.
Packit a69f91
Packit a69f91
In contrast, I believe that an FAQ should literally be a list of
Packit a69f91
frequently asked questions and little else.  An FAQ should not be a
Packit a69f91
replacement for good documentation.
Packit a69f91
Packit a69f91
In that sense, I have tried to use this FAQ as a second place to
Packit a69f91
look rather than a first place.  The place you should always look
Packit a69f91
first is Exploring Expect.  At over 600 pages, the book is very
Packit a69f91
comprehensive, well-organized, and includes three indices and two
Packit a69f91
tables-of-contents to make it very easy to find what you want to know.
Packit a69f91
Packit a69f91
The book was not a rush job.  During the three years I spent
Packit a69f91
writing it, virtually every question I was asked became incorporated
Packit a69f91
as subject material for the book.  I wanted to make sure that the book
Packit a69f91
wouldn't need much of an FAQ!
Packit a69f91
Packit a69f91
It would not make sense to try and distill the entire book into an
Packit a69f91
FAQ (that is actually comprehensive rather that truly frequently asked
Packit a69f91
questions).  There's simply too much material there.
Packit a69f91
Packit a69f91
So this FAQ is short.  It really tries to stick just to *truly*
Packit a69f91
frequently asked questions.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#9. How was this FAQ created?
Packit a69f91
Packit a69f91
The Expect FAQ is regularly recreated by a Tcl script which
Packit a69f91
produces either text or HTML depending on how it is called.  Using Tcl
Packit a69f91
has two nice results:
Packit a69f91
   +  I didn't have to choose one format and worry about
Packit a69f91
converting it to the other.  (Remember that the FAQ appears in HTML on
Packit a69f91
the web and it appears in text in the Expect distribution.)  The more
Packit a69f91
common approach - doing conversions in either direction - is really
Packit a69f91
painful - plus, it's now easy to generate other formats, too.
Packit a69f91
   +  It's much, much easier to keep track of questions and
Packit a69f91
answers.  For example, when I add a new question, I don't have to add
Packit a69f91
it twice (once at the top and again later with the answer), nor do I
Packit a69f91
have to worry about making the links between them.  All this and a lot
Packit a69f91
of other stuff is handled automatically - and the source is much more
Packit a69f91
readable than the actual HTML.
Packit a69f91
(see "FAQbuilder")
Packit a69f91
Packit a69f91
You can read about these ideas in a paper that appeared at Tcl '96
Packit a69f91
called Writing CGI Scripts in Tcl.  (CGI scripts are the primary focus of the
Packit a69f91
paper, but it also spends time on HTML generation for other purposes -
Packit a69f91
including the example of highly stylized documents like FAQs.)
Packit a69f91
Packit a69f91
I encourage you to examine the source to this FAQ - it
Packit a69f91
comes in two parts:
Packit a69f91
   +  Expect-specific FAQ source
Packit a69f91
   +  Generic FAQ Builder source
Packit a69f91
Packit a69f91
The generic FAQ builder has also been used to build several other
Packit a69f91
FAQs (unrelated to Expect).
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#10. The background makes the FAQ hard to read.
Packit a69f91
Packit a69f91
To: bonneau@mudd.csap.af.mil (Allen Bonneau)
Packit a69f91
Subject: FAQ background colors
Packit a69f91
Date: Wed, 10 Apr 96 10:24:52 EDT
Packit a69f91
Packit a69f91
Allen Bonneau writes:
Packit a69f91
>... the white and gray background makes the FAQ difficult to read.
Packit a69f91
Packit a69f91
It's not white and gray.  It's several very close shades of gray.
Packit a69f91
It's supposed to be very subtle.  Sounds like you have your browser in
Packit a69f91
a mode where it is mishandling colors.  Turn on dithering and
Packit a69f91
restart your browser.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#11. Why isn't there an Expect mailing list?
Packit a69f91
Packit a69f91
From: libes (Don Libes)
Packit a69f91
To: dclark@nas.nasa.gov (David R. Clark)
Packit a69f91
Subject: Mailing list for Expect
Packit a69f91
Date: Mon, 23 Sep 91 18:21:28 EDT
Packit a69f91
Packit a69f91
>Would be nice if their were an Expect mailing list.  I would use it more
Packit a69f91
>often, and be made aware of other users.
Packit a69f91
Packit a69f91
Perhaps I'm too myopic, but I don't see the need for it.  Most of
Packit a69f91
the questions about Expect posted to Usenet every day can be found in
Packit a69f91
the various FAQs or in the book, so it's pretty easy getting
Packit a69f91
answers to them.
Packit a69f91
Packit a69f91
For one reason or another (occasionally a bug fix, but often, just
Packit a69f91
adding a neat example), I update Expect every couple of weeks.
Packit a69f91
Personally, I'd hate being on the other end of something like this.
Packit a69f91
Who needs patches every two weeks for problems that are likely not
Packit a69f91
even relevant to you?  (Most patches these days are either extremely
Packit a69f91
esoteric or are related to porting Expect to some unusual machine.)
Packit a69f91
Packit a69f91
>It would be helpful, too, if this served as an area for swapping programs.
Packit a69f91
>Many of the things that I want to do are done by others already.
Packit a69f91
Packit a69f91
NIST doesn't distribute software written by other people but if
Packit a69f91
you've got relatively small scripts that show off unique ideas and
Packit a69f91
techniques that would be educational for the Expect community, I can
Packit a69f91
include your script with Expect or put it in a publicly accessible
Packit a69f91
directory so other people can get it.  I'm also willing to list links
Packit a69f91
in Expect's home page to other web pages about projects that use
Packit a69f91
Expect.
Packit a69f91
Packit a69f91
There is a Tcl newsgroup, comp.lang.tcl, which many Expect users
Packit a69f91
read.  It's pretty good for asking questions about Tcl, and many of
Packit a69f91
the readers use Expect so Expect questions are encouraged.  The
Packit a69f91
newsgroup is gatewayed to a mailing list (tcl@sprite.berkeley.edu)
Packit a69f91
which is further described in the Tcl documentation.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#12. Why isn't overlay covered in Exploring Expect?
Packit a69f91
Packit a69f91
To: spaf@cs.purdue.edu
Packit a69f91
Packit a69f91
Gene Spafford writes:
Packit a69f91
>I'm curious as to why the "overlay" command is not mentioned anywhere
Packit a69f91
>in the book.  Is that a recent addition?  A deprecated feature?  I
Packit a69f91
>ended up using it in one of my scripts....
Packit a69f91
Packit a69f91
The overlay command has been in Expect for a long time.  In all that
Packit a69f91
time no one has ever asked me about it and I have never used it.
Packit a69f91
Well, I used it once but I really didn't like the result, and so I
Packit a69f91
rewrote the script to not use it.  I left the overlay command in
Packit a69f91
Expect because it seemed like an interesting idea, but I never really
Packit a69f91
finished it - in the sense that I believe it needs some more options
Packit a69f91
and controls.  In comparison, the interact command is very flexible
Packit a69f91
and makes the need for overlay pretty moot.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#13. Is the front cover of your book a self portrait (ha ha)?
Packit a69f91
Packit a69f91
From: libes (Don Libes)
Packit a69f91
To: pkinz@cougar.tandem.com (kinzelman_paul)
Packit a69f91
Subject: the cover?
Packit a69f91
Packit a69f91
kinzelman paul writes:
Packit a69f91
>The book finally came in. I tried to buy 4 copies but they had only 2
Packit a69f91
>left and they came in last Saturday. Move over Stephen King! :-)
Packit a69f91
Packit a69f91
4 copies!?  Wow.  That's more than my mother bought!
Packit a69f91
Packit a69f91
>I was discussing your book with somebody who stopped in and we began
Packit a69f91
>to speculate about the monkey on the cover. I don't suppose it's a
Packit a69f91
>self portrait? :-)
Packit a69f91
Packit a69f91
There is some real humor here.  There seems to be considerable
Packit a69f91
debate over what the creature is!  The colophon at the end of the book
Packit a69f91
says that it is a chimpanzee.  I like that idea much more than a
Packit a69f91
monkey which is what it looks like to me.  My wife, who has a degree
Packit a69f91
in zoology, explained to me that chimps are actually the second
Packit a69f91
smartest of primates (humans are the smartest).  Chimps are very
Packit a69f91
intelligent and can do many things (but not everything) that humans
Packit a69f91
do.  Perfect for describing Expect.  Anyway, she says I should be
Packit a69f91
honored to have it grace the cover - even in theory.
Packit a69f91
Packit a69f91
I remarked to Edie (the cover designer at O'Reilly) that even though
Packit a69f91
the cover was nice looking, everyone was going to stare at it and say,
Packit a69f91
"Gee, but it looks like a monkey."  She replied "The purpose of the
Packit a69f91
cover is just to get people to pick the book up. This cover will do
Packit a69f91
that. Don't worry. If you get any rude comments from anyone, at least
Packit a69f91
you know they are paying attention."
Packit a69f91
Packit a69f91
[After being inundated by people pointing out that the animal
Packit a69f91
really is a monkey, O'Reilly subsequently decided to acquiesce and has
Packit a69f91
changed the colophon to admit that yes it is a rhesus monkey.
Packit a69f91
Evidentally, the book from which O'Reilly has been taking those
Packit a69f91
pictures from was wrong on this one.]
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#14. Why don't the examples in your USENIX papers work?
Packit a69f91
Packit a69f91
From: libes (Don Libes)
Packit a69f91
To: Will Smith (AC) <william@ritchie.acomp.usf.edu>
Packit a69f91
Subject: Expect
Packit a69f91
Packit a69f91
Will Smith (AC) writes:
Packit a69f91
>I just entered some scripts from a USENIX paper that my boss had.  I get
Packit a69f91
>errors about my quotes in the script.  Also, it doesn't seem to know
Packit a69f91
>about expect_match.  Thanks in advance for any insight you could offer.
Packit a69f91
Packit a69f91
The USENIX papers are old and out-of-date as far as quoting goes.  A
Packit a69f91
couple years ago, I cleaned up and simplified this aspect of Expect.
Packit a69f91
Similarly, expect_out is now where the results of expect's pattern
Packit a69f91
matching are saved.
Packit a69f91
Packit a69f91
The man page is always the best reference on what Expect currently
Packit a69f91
supports.  Alternatively, you can read the CHANGES files.  These files
Packit a69f91
document the changes from one major version to another.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#15. Can you put the examples in your book into an anonymous ftp site?
Packit a69f91
Packit a69f91
From: libes (Don Libes)
Packit a69f91
To: pren@cs.umass.edu
Packit a69f91
Subject: Examples in your book "Exploring Expect"
Packit a69f91
Packit a69f91
Peifong Ren writes:
Packit a69f91
>
Packit a69f91
>Hi,
Packit a69f91
>
Packit a69f91
>I bought your book "Exploring Expect" from O'Reilly.
Packit a69f91
>I wonder can you put the eamples in your book into an anonymous ftp
Packit a69f91
>site?
Packit a69f91
Packit a69f91
All of the substantive examples come with recent versions of Expect.
Packit a69f91
Just look in the example directory.  
Packit a69f91
Packit a69f91
The remaining 50 or so examples are short enough that typing them
Packit a69f91
in only takes a minute or two.  If I put them online, you'd spend more
Packit a69f91
time looking for them (reading my online catalog, figuring out what
Packit a69f91
the online descriptions meant, mapping them back to the file, etc.)
Packit a69f91
then it would take to type them in.  And since you're likely to want
Packit a69f91
to change the examples anyway, there's nothing to be gained for short
Packit a69f91
ones.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#16. Do you have ideas for more articles on Expect?
Packit a69f91
Packit a69f91
From: libes (Don Libes)
Packit a69f91
To: faught@zeppelin.convex.com (Danny R. Faught)
Packit a69f91
Cc: libes
Packit a69f91
Subject: Re: SQA Quarterly articles
Packit a69f91
Date: Thu, 21 Dec 95 13:31:01 EST
Packit a69f91
Packit a69f91
Danny R. Faught writes:
Packit a69f91
>I just arranged to write an article on automating interactive
Packit a69f91
>processes for an issue early next year.  You have so many good pieces
Packit a69f91
>on expect out there, it's going to be hard to add anything original.
Packit a69f91
Packit a69f91
One thing I've never written is a good mini-tutorial.  Magazine
Packit a69f91
editors love these types of pieces and there's certainly a need for
Packit a69f91
it.  So I'd encourage that type of article.
Packit a69f91
Packit a69f91
Another possibility is an article on how you or your colleagues
Packit a69f91
personally applied Expect to solve your particular problem. Application-
Packit a69f91
oriented papers are the kind that necessarily have to be written by
Packit a69f91
people in the field who are applying the technology.  People love this
Packit a69f91
kind of practical paper.  For example, a good paper might be "Writing
Packit a69f91
a pager".  This is a nice topic because you can start with a simple
Packit a69f91
5-line script that solves the problem and then show progressive
Packit a69f91
refinements that handle different twists on the same problem.  (And
Packit a69f91
"how to write a pager" is a very frequently asked question on Usenet.)
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
**** Can Expect do this? **** 
Packit a69f91
Packit a69f91
Packit a69f91
#17. Can Expect automatically generate a script from watching a session?
Packit a69f91
Packit a69f91
From: libes (Don Libes)
Packit a69f91
To: pete@willow24.cray.com
Packit a69f91
Subject: Expect
Packit a69f91
Date: Fri, 12 Oct 90 17:16:47 EDT
Packit a69f91
Packit a69f91
>I like "Expect" and am thinking of using it to help automate the
Packit a69f91
>testing of interactive programs.  It would be useful if Expect had a
Packit a69f91
>"watch me" mode, where it "looks over the shoulder" of the user and
Packit a69f91
>records his keystrokes for later use in an Expect script.
Packit a69f91
>
Packit a69f91
>(Red Ryder and other Macintosh telecommunications packages offer this
Packit a69f91
>sort of thing.  You log onto Compuserve once in "watch me" mode, and
Packit a69f91
>RR keeps track of the keystrokes/prompts.  When you're done you have a
Packit a69f91
>script that can be used to log onto Compuserve automatically.)   
Packit a69f91
>
Packit a69f91
>Before I look into adding a "watch me" feature, I thought I should
Packit a69f91
>ask: has this been done already?
Packit a69f91
>
Packit a69f91
>I'll say again that I like the tool a lot--nice work!  There are other
Packit a69f91
>people here using it for things like the testing of ksh, which
Packit a69f91
>responds differently to signals when not used interactively.
Packit a69f91
>
Packit a69f91
>-- Pete
Packit a69f91
Packit a69f91
The autoexpect script in Expect's example directory does what you
Packit a69f91
want.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#18. Can Expect understand screen-oriented (Curses) programs?
Packit a69f91
Packit a69f91
Yes, it can - with a little clever scripting.  Look at the
Packit a69f91
term_expect script for an example.  It uses a Tk text widget to
Packit a69f91
support screen-oriented Expect commands.  This technique is described
Packit a69f91
very thoroughly in Chapter 19 of Exploring Expect.
Packit a69f91
Packit a69f91
Adrian Mariano (adrian@cam.cornell.edu) converted the term_expect
Packit a69f91
code (see above) so that it runs without Tk (exercise 4 in Chapter
Packit a69f91
19!)  Both term_expect and virterm can be found in the example
Packit a69f91
directory that comes with Expect.
Packit a69f91
Packit a69f91
An alternative approach to screen-handling was demonstrated by Mark
Packit a69f91
Weissman (weissman@gte.com) and Christopher Matheus who modified a
Packit a69f91
version of Expect to include a built-in Curses emulator.  It can be
Packit a69f91
ftp'd from the Tcl archive as expecTerm1.0beta.tar.Z.  (Note that
Packit a69f91
Expecterm does not run with the current version of Expect.)
Packit a69f91
Packit a69f91
I like the idea of keeping the curses emulator outside of Expect
Packit a69f91
itself.  It leaves the interface entirely defineable by the user.  And
Packit a69f91
you can do things such as define your own terminal types if you want.
Packit a69f91
For these reasons and several others, I'm not likely to return to
Packit a69f91
Expecterm.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#19. Can Expect be run as a CGI script?
Packit a69f91
Packit a69f91
Expect scripts work fine as CGI scripts.  A couple pointers might
Packit a69f91
help to get you going:
Packit a69f91
Packit a69f91
Many Expect scripts can be run directly with one change - the
Packit a69f91
following line should be inserted before any other output:
Packit a69f91
Packit a69f91
puts "Content-type: text/html\n"
Packit a69f91
Packit a69f91
Be sure not to forget that extra newline at the end of the puts.
Packit a69f91
Packit a69f91
Next, make sure you invoke external programs using full paths.  For
Packit a69f91
example, instead of "spawn telnet", use "spawn /usr/ucb/telnet" (or
Packit a69f91
whatever).  Remember that the PATH and other environment variables are
Packit a69f91
going to be different than what you are used to.  This is very similar
Packit a69f91
to dealing with cron and you can get other good tips and advice from
Packit a69f91
reading the Background chapter in the book.
Packit a69f91
Packit a69f91
 Another tip: If a script runs fine by hand but not from CGI, just
Packit a69f91
log in as "nobody" to the host on which your CGI script runs.  Then
Packit a69f91
try running it by hand.  This generally makes it very obvious what's
Packit a69f91
going on.  (If you can't log in to the server or can't log in as
Packit a69f91
"nobody", use the kibitz trick described in the Background chapter.)
Packit a69f91
Packit a69f91
You may find it helpful to use cgi.tcl, a nice collection of
Packit a69f91
CGI support utilities for Tcl scripts.  It includes an Expect example
Packit a69f91
among many others.  The package includes just about everything:
Packit a69f91
tables, frames, cookies, file upload, etc...., with some nice
Packit a69f91
debugging support.  It's pure Tcl, no C code - so it's very easy to
Packit a69f91
try out and use.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#20. Can Expect act like a browser and retrieve pages or talk to a CGI script?
Packit a69f91
Packit a69f91
From: jasont@netscape.com (Jason Tu)
Packit a69f91
Date: Sat, 02 Nov 1996 09:51:03 -0800
Packit a69f91
Packit a69f91
I read your book "Exploring Expect" and find Expect is just the tool
Packit a69f91
to test Netscape's enterprise server product, since it is very easy to
Packit a69f91
use and quick to develop. I figured I would use telnet to send HTTP
Packit a69f91
protocol dialog to a HTTP server and simulate how it behaves.  But I
Packit a69f91
couldn't get it to work at all.  I am wondering that there might be a
Packit a69f91
quick example that you can share with me.
Packit a69f91
Packit a69f91
Yes, this is a useful way of testing HTTP servers and running CGI
Packit a69f91
scripts (and winning Web contests :-).  You can add error checking and
Packit a69f91
other stuff, but here's the minimum your script should have to read a
Packit a69f91
web page: 
Packit a69f91
Packit a69f91
match_max 100000
Packit a69f91
set timeout -1
Packit a69f91
spawn telnet $host 80
Packit a69f91
expect "Escape character is *\n"
Packit a69f91
send "GET $page\r\n"
Packit a69f91
expect
Packit a69f91
puts "$expect_out(buffer)"
Packit a69f91
Packit a69f91
If you want to communicate information to a CGI script, you'll want
Packit a69f91
more.  One way to see what needs to be sent is to load a real browser
Packit a69f91
with the form and then send it to a fake daemon such as this one:
Packit a69f91
Packit a69f91
#!/bin/sh
Packit a69f91
/bin/cat -u > /tmp/catlog
Packit a69f91
Packit a69f91
Enable this by adding this service to inetd.  Then save the form in
Packit a69f91
a temporary file, modify the form's host and port to correspond to
Packit a69f91
your own host and whatever port you've chosen to associate with your
Packit a69f91
fake daemon.  Now fill out the form and you'll find the form data in
Packit a69f91
/tmp/catlog.  Using this, you can determine exactly how to amend your
Packit a69f91
Expect script to behave like your browser.  
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#21. Can Expect be run from cron?
Packit a69f91
Packit a69f91
Expect itself works fine from cron - however, you can cause
Packit a69f91
problems if you do things that don't make sense in cron - such as
Packit a69f91
assume that there is a terminal type predefined.  There are a number
Packit a69f91
of other pitfalls to watch out for.  The list and explanations aren't
Packit a69f91
short - which is why there's a whole chapter ("Background") on the
Packit a69f91
subject in the book.
Packit a69f91
Packit a69f91
Here's one that someone tried to stump me with recently: They told
Packit a69f91
me that their program started up and then Expect immediately exited.
Packit a69f91
We spent a lot of time tracking this down (Was the spawned program
Packit a69f91
really starting up but then hanging - which would indicate a bug in
Packit a69f91
the program; or was the program NOT starting up - which would indicate
Packit a69f91
a bug in the environment; etc.)  Turned out that Expect wasn't even
Packit a69f91
running their program.  They had assumed cron honored the #! line
Packit a69f91
(which it doesn't) and so the first line in their script (exec date)
Packit a69f91
was being interpreted by the shell and of course, the script did
Packit a69f91
nothing after that - because that's what the shell's exec is supposed
Packit a69f91
to do!)
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#22. Why does my Expect script not work under inetd?
Packit a69f91
Packit a69f91
From: dpm@bga.com (David P. Maynard)
Packit a69f91
Subject: Re: Tcl/Expect, inetd service, and no echo password
Packit a69f91
Date: 24 Oct 1996 13:34:57 -0500
Packit a69f91
Packit a69f91
In article <54ocsh$9i1@urchin.bga.com> dpm@bga.com (David P. Maynard) writes:
Packit a69f91
   I am fairly new to expect, so hopefully this isn't too obvious.  I also
Packit a69f91
   confess to not having looked in "Exploring Expect" becuase I haven't
Packit a69f91
   found it in stock at a local bookstore yet.
Packit a69f91
Packit a69f91
   I want to write an expect script that runs as a service from inetd.
Packit a69f91
   (Actually, I plan to use the tcpd 'twist' command to launch the
Packit a69f91
   binary, but that doesn't seem to affect the problem.)  The script will
Packit a69f91
   prompt the user for a password.  The supplied password is used as a
Packit a69f91
   key to decrypt some passwords stored online.  The script then fires
Packit a69f91
   off a telnet session to a remote box and does some fairly simple
Packit a69f91
   things that require the decrypted passwords.
Packit a69f91
Packit a69f91
   I have all of this working when I run the script from a UNIX prompt.
Packit a69f91
   However, when I run it out of inetd, the 'stty -echo' commands that
Packit a69f91
   turn off character echo when the user types the password fail with the
Packit a69f91
   following error:
Packit a69f91
Packit a69f91
   stty: impossible in this context
Packit a69f91
   are you disconnected or in a batch, at or cron script?
Packit a69f91
   stty: ioctl(user): Bad file descriptor
Packit a69f91
Packit a69f91
   I can understand the cause of the message (no associated tty), but I
Packit a69f91
   can't think of an easy solution.  If I use 'gets' or 'expect_user,'
Packit a69f91
   the user's input is always echoed.  I tried a few variations on the
Packit a69f91
   stty command, but didn't have any luck.
Packit a69f91
Packit a69f91
   Any suggestions?
Packit a69f91
Packit a69f91
Yes, read Exploring Expect, Chapter 17 (Background Processing).  In
Packit a69f91
the section "Expect as a Daemon", there's a very thorough discussion
Packit a69f91
of this problem and how to solve it.
Packit a69f91
Packit a69f91
 
Packit a69f91
In short, there's no tty when you run a process from inetd.  Echoing
Packit a69f91
is controlled by the telnet protocol, so you must send and expect
Packit a69f91
telnet protocol packets to solve the problem.  Even knowing this, the
Packit a69f91
actual implementation is very non-obvious which is why the book goes
Packit a69f91
into it in such detail.  
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
**** Compilation or porting questions **** 
Packit a69f91
Packit a69f91
Packit a69f91
#23. Why can't I compile Expect with Tcl 8.0?
Packit a69f91
Packit a69f91
Sounds like you have an old version of Expect.  Get a a new version of Expect.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#24. Does Expect 5.26 work with Tcl/Tk 8.0.3?
Packit a69f91
Packit a69f91
To: aspi@cisco.com
Packit a69f91
Subject: Re: Expect 5.26 and TCL 8.0
Packit a69f91
Aspi Siganporia writes:
Packit a69f91
>
Packit a69f91
>Hi Don,
Packit a69f91
>
Packit a69f91
>We are looking at upgrading Expect. Our last version was Expect5.22
Packit a69f91
>
Packit a69f91
>I see that Expect5.26 supports TCL 8.0.
Packit a69f91
>
Packit a69f91
>The question is, 
Packit a69f91
>
Packit a69f91
>Will it work with TCL8.0.3?
Packit a69f91
>
Packit a69f91
>Thanks
Packit a69f91
>Aspi
Packit a69f91
Packit a69f91
It might.  8.0.3 broke a couple of the more esoteric configurations.
Packit a69f91
If you find that you can't compile using 5.26, get 5.27.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#25. Why can't I compile Expect with Tcl/Tk 8.1aX?
Packit a69f91
Packit a69f91
Historically, I've rarely found the time to port Expect to alphas
Packit a69f91
and betas.  I recommend you stick with 8.0 unless you're willing to do
Packit a69f91
a little work.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#26. Why can't I compile Expect with Tcl/Tk 8.0b1?
Packit a69f91
Packit a69f91
I don't see the point in supporting an old beta.  Upgrade to the
Packit a69f91
production release of Tcl/Tk 8.0.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#27. Why does Expect need to be setuid root on Cray?
Packit a69f91
Packit a69f91
From: libes (Don Libes)
Packit a69f91
To: u70217@f.nersc.gov (Lori Wong)
Packit a69f91
Subject: setuid in Expect
Packit a69f91
Date: Thu, 24 Oct 91 16:15:20 EDT
Packit a69f91
Packit a69f91
>     I have been running Expect now under UNICOS 6.1 and CSOS 1.0 (Cray
Packit a69f91
>Computer Corporation's OS).  The two machines that I am running Expect
Packit a69f91
>on have stringent security features, one of which is to limit setuid
Packit a69f91
>privileges to specific individuals.  I was wondering if you would be
Packit a69f91
>kind enough to explain the purpose of the setuid that is needed by Expect
Packit a69f91
>and whether it could be compiled to run without having to have setuid
Packit a69f91
>privilege?  I know it has to do with spawning and communicating with
Packit a69f91
>the various spawned tasks, but don't know enough of the details to be
Packit a69f91
>able to explain why Expect specifically needs setuid and whether or not
Packit a69f91
>it could cause a security problem (could someone use it to enter into
Packit a69f91
>the system and wreak havoc, for example?).  Right now, I've limited
Packit a69f91
>the access of Expect to my group, but need to know what the security
Packit a69f91
>implications are if I open it to all users.  I'd appreciate any light
Packit a69f91
>you can shed on this subject...
Packit a69f91
Packit a69f91
Root-access is needed to open a pty under Unicos.  Thus, all programs
Packit a69f91
accessing ptys must be setuid root.  If you do an "ls -l" of programs
Packit a69f91
like "script", "xterm", etc, you'll see this.
Packit a69f91
Packit a69f91
I have no idea why this is.  The requirement was probably for security
Packit a69f91
reasons to begin with, but it has the ironic effect of making more
Packit a69f91
programs require setuid and therefore greater possibility of errant
Packit a69f91
setuid programs.
Packit a69f91
Packit a69f91
In fact, there is one known Unicos bug relating to the way uids are
Packit a69f91
switched at exec time which requires further special coding.  If you
Packit a69f91
search for "Cray" in the Expect source you will see significant chunks
Packit a69f91
of code to get around the problem.
Packit a69f91
Packit a69f91
I don't know if this reassures you any.  All I can tell you is that a
Packit a69f91
number of Cray experts have looked into the situation and are happy
Packit a69f91
with the current implementation of Expect.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#28. Does Expect run on VMS?
Packit a69f91
Packit a69f91
From: libes (Don Libes)
Packit a69f91
To: Cameron Laird <claird@Starbase.NeoSoft.COM>
Packit a69f91
Subject: VMS question.
Packit a69f91
Packit a69f91
Cameron Laird writes:
Packit a69f91
>Do you know of anyone working with Expect and VMS?
Packit a69f91
>I'd like not to re-invent wheels, but, if I'm to be
Packit a69f91
>the first one, I want others to benefit.
Packit a69f91
Packit a69f91
No, I'm not aware of anyone doing it.  Since VMS claims POSIX
Packit a69f91
conformance, it shouldn't be that hard - Expect uses the POSIX calls
Packit a69f91
if it can.  Probably the hardest part will just be modifying the Makefile
Packit a69f91
and the configure script!
Packit a69f91
Packit a69f91
However, that there might be a simpler solution.  The neat thing
Packit a69f91
about Expect is that you can control other computers easily.  Run
Packit a69f91
Expect on your UNIX box and have it log in to the VMS box and do its
Packit a69f91
thing.  (You can bypass the login garbage by using an inet daemon.)
Packit a69f91
We've done exactly this to a number of weird pieces of hardware we
Packit a69f91
have around the lab (robots, Lisp machines, embedded controllers, and,
Packit a69f91
of course, a VAX running VMS).  It saves time porting!
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#29. Is it possible to use Expect and TclX together?
Packit a69f91
Packit a69f91
Is it possible to use Expect and TclX together?
Packit a69f91
From: bfriesen@iphase.com (Bob Friesenhahn)
Packit a69f91
Date: 20 Jul 1994 04:09:43 GMT
Packit a69f91
Organization: Interphase Corporation, Dallas TX - USA
Packit a69f91
Packit a69f91
Jeffery A. Echtenkamp (echtenka@michigan.nb.rockwell.com) wrote:
Packit a69f91
: Do Expect and tclX work together? If so, must anything special be done to 
Packit a69f91
: get them to work together?
Packit a69f91
Packit a69f91
This answer courtesy of Bob Friesenhahn, Interphase (bfriesen@iphase.com):
Packit a69f91
Packit a69f91
They work fine together.  However, you should prepend "exp_" to your Expect
Packit a69f91
command names.  This will ensure that there are no conflicts between Expect
Packit a69f91
commands and tclX commands of the same name (like wait).
Packit a69f91
Packit a69f91
Just pick up the "make-a-wish" package, follow the instructions, and you will
Packit a69f91
be all set.  I have built a wish based on tcl, tk, Expect, tclX, and dp using
Packit a69f91
this technique with no observed problems.
Packit a69f91
Packit a69f91
Bob
Packit a69f91
Packit a69f91
[If you need additional information, please read Chapter 22
Packit a69f91
("Expect as Just Another Tcl Extension") of Exploring Expect.  Its
Packit a69f91
sole focus is how to make Expect work with other extensions. - Don]
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#30. Is it possible to use Expect and <lots of random extensions> together?
Packit a69f91
Packit a69f91
From: libes (Don Libes)
Packit a69f91
To: Frank Winkler <winkler@eas.iis.fhg.de>
Packit a69f91
Subject: Q Expect + TkSteal
Packit a69f91
Packit a69f91
Frank Winkler writes:
Packit a69f91
>Hi don,
Packit a69f91
>
Packit a69f91
>a short question considering installation of Expectk.
Packit a69f91
>
Packit a69f91
>Is it possible to build an Expectk-binary, which uses 
Packit a69f91
>the features of BLT, TkSteal and Expect ?
Packit a69f91
Packit a69f91
I've never done it, but I know it must be possible because the tgdb
Packit a69f91
package in the Tcl archive uses all of those extensions with Expect.
Packit a69f91
Packit a69f91
Expect is a "well-behaved extension" in the sense that it requires no
Packit a69f91
changes to the Tcl core.  So Expect should work with any other Tcl
Packit a69f91
extensions.  You just need to add the usual Exp_Init call to main() or
Packit a69f91
the other _Init calls to Expect's main.
Packit a69f91
Packit a69f91
>If yes, which of them should be build first, second ... ?
Packit a69f91
Packit a69f91
Order doesn't matter.
Packit a69f91
Packit a69f91
I've done this kind of thing by hand.  It's pretty simple.  But people
Packit a69f91
tell me the make-a-wish package in the Tcl archive automates the
Packit a69f91
creation of multi-extension Tcl applications.
Packit a69f91
Packit a69f91
[Also see the answer to the previous FAQ answer.]
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#31. Why does configure complain about "cross-compiling"?
Packit a69f91
Packit a69f91
From: libes (Don Libes)
Packit a69f91
To: morton@hendrix.jci.tju.edu (Dan Morton)
Packit a69f91
Subject: Re: Sorry to bother you, but...
Packit a69f91
Packit a69f91
Dan Morton writes:
Packit a69f91
>Don,
Packit a69f91
>
Packit a69f91
>I've posted an inquiry to comp.lang.tcl about my configure problems with
Packit a69f91
>expect, but I've not yet gotten a reply.  Perhaps you can nudge me in the
Packit a69f91
>right direction?
Packit a69f91
>
Packit a69f91
>I'm running HP-UX 9.0 on a 735, and I've snagged the latest versions of Tcl
Packit a69f91
>and expect from NIST (7.4 and 5.18 respectively).  My gcc is v2.6.  Tcl
Packit a69f91
>configured and built out of the box, but I can't get expect to configure
Packit a69f91
>properly.  No matter what I do, it thinks it wants to cross-compile.  I
Packit a69f91
>think it's failing that little snippet of eval code.  It gets further if I
Packit a69f91
>specify --host=HP, but still complains about cross compiling.  Here's the
Packit a69f91
>result without options:
Packit a69f91
>
Packit a69f91
>{hendrix:~/expect-5.18:8} ./configure
Packit a69f91
>checking for gcc... gcc
Packit a69f91
>checking whether we are using GNU C... yes
Packit a69f91
>checking whether gcc accepts -g... no
Packit a69f91
>checking how to run the C preprocessor... gcc -E
Packit a69f91
>checking whether cross-compiling... yes
Packit a69f91
>checking whether cross-compiling... (cached) configure: error: You need to
Packit a69f91
>specify --target to cross compile,
Packit a69f91
>        or the native compiler is broken
Packit a69f91
Packit a69f91
I guess the error message has to be clearer.  The message:
Packit a69f91
Packit a69f91
	"or the native compiler is broken"
Packit a69f91
Packit a69f91
means that configure tried to compile a simple program and it failed.
Packit a69f91
Here's the program it tries to compile:
Packit a69f91
Packit a69f91
	main() {
Packit a69f91
		return(0);
Packit a69f91
	}
Packit a69f91
Packit a69f91
The configure output that you showed me says that it found gcc.
Packit a69f91
Perhaps it was misinstalled or is just a placeholder and doesn't
Packit a69f91
actually do anything?  Try compiling a tiny C program yourself from
Packit a69f91
the command line.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#32. Why are make/configure looping endlessly?
Packit a69f91
Packit a69f91
To: Xiaorong Qu <aqu@cisco.com>
Packit a69f91
Subject: Make message for Expect
Packit a69f91
--text follows this line--
Packit a69f91
Xiaorong Qu writes:
Packit a69f91
>Don, 
Packit a69f91
>
Packit a69f91
>The following is the output of make, you can find 
Packit a69f91
>that the process repeated three times.
Packit a69f91
Packit a69f91
I bet what's going on is that your system clock is set to some
Packit a69f91
ridiculous time such as last year.  "Make" is sensitive to your clock.
Packit a69f91
Please fix your clock.  Then check that all the files are "older"
Packit a69f91
than the current time.  (If not, "touch" them all.)
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#33. Why does compile fail with: Don't know how to make pty_.c?
Packit a69f91
Packit a69f91
From: libes (Don Libes)
Packit a69f91
To: wren@io.nosc.mil
Packit a69f91
Subject: Compile fails with: Don't know how to make pty_.c
Packit a69f91
Packit a69f91
>   I'm trying to compile Expect on hpux 9.01, 
Packit a69f91
>   downloaded from ftp.cme.nist.gov expect.tar
Packit a69f91
Packit a69f91
>   after running config
Packit a69f91
>   the make fails with  "Don't know how to make pty_.c. (compile fails)
Packit a69f91
>   I see three versions pty_sgttyb.c, pty_termios.c and pty_unicos.c in
Packit a69f91
>   the load, but the configure picked none of them.
Packit a69f91
>   I tried forcing to pty_termios.c but that failed with other compile errors.
Packit a69f91
Packit a69f91
I've seen this happen because gcc was partially installed.  configure
Packit a69f91
finds the gcc stub and uses gcc for all the tests.  But because the
Packit a69f91
compiler doesn't work, every test fails so configure doesn't select
Packit a69f91
any of the choices.
Packit a69f91
Packit a69f91
So either finish installing gcc or delete the stub.
Packit a69f91
Packit a69f91
(And if it's not that, then something similar is wrong with whatever
Packit a69f91
compiler you've got.  Look closely at the output from configure, it
Packit a69f91
will tell you what compiler it is trying to use.)
Packit a69f91
Packit a69f91
By the way, Expect compiles fine on my HP (A.09.05 E 9000/735).
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#34. Does Expect run on MSDOS, Win95, WinNT, MacOS, etc...?
Packit a69f91
Packit a69f91
Gordon Chaffee has ported Expect to NT.  I would like to unify the
Packit a69f91
UNIX and NT code but I probably won't have the time to do this
Packit a69f91
personally.  Volunteers are welcome.
Packit a69f91
Packit a69f91
I have no plans to do other ports.  Feel free to volunteer.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#35. Why does Expect dump core?  Why can I run Expect as root but not as myself?
Packit a69f91
Packit a69f91
From: Wayne Tcheng <wmt@visi.net>
Packit a69f91
Subject: Expect on Solaris
Packit a69f91
Date: Wed, 2 Apr 97 21:34:50 EST
Packit a69f91
Packit a69f91
I've compiled Expect 5.21 with Tcl 7.6 and Tk 4.2.  Whenever I run Expect
Packit a69f91
as a non-root user, it core dumps.  When I am root, I can run it
Packit a69f91
successfully.  However, if I "su - wmt" to my own id, I can also run it
Packit a69f91
without a problem.  I've tried making the expect binary suid root, but
Packit a69f91
that does not help either.  I'm on Solaris 2.5.  Any ideas?
Packit a69f91
Packit a69f91
Sounds like something on your system is misconfigured.  Everytime
Packit a69f91
I've had reports like this (works as root, not as user), it's turned
Packit a69f91
out to be /tmp was unwriteable or something equally improbable.
Packit a69f91
Packit a69f91
The easiest way to find out is to use the debugger and tell me where
Packit a69f91
Expect is dumping core.  (If you don't understand this statement, ask
Packit a69f91
a local C or C++ programmer.)
Packit a69f91
Packit a69f91
As an aside, you should be using the most recent version of Expect
Packit a69f91
(currently 5.22.1).  But I don't know of any problems in 5.21 that
Packit a69f91
caused core dumps, so it's certainly worth trying the debugger
Packit a69f91
approach before retrieving the latest version.  But if you do find a
Packit a69f91
bug in Expect, before reporting it, please verify that it still exists
Packit a69f91
in the current version.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
**** Other... **** 
Packit a69f91
Packit a69f91
Packit a69f91
#36. Is it possible to prevent Expect from printing out its interactions?
Packit a69f91
Packit a69f91
From: libes (Don Libes)
Packit a69f91
To: Sunanda Iyengar <sunanda@simvax.labmed.umn.edu>
Packit a69f91
Subject: Disabling display from Expect
Packit a69f91
Packit a69f91
Sunanda Iyengar writes:
Packit a69f91
>Is it possible to have Expect interact with a process and not print-out
Packit a69f91
>the results of interaction? In my application, I need it to go into a 
Packit a69f91
>silent mode, communicate with a process without reporting to the user, and
Packit a69f91
>then come back to normal mode and  put the process into interactive mode.
Packit a69f91
Packit a69f91
Use the following command:
Packit a69f91
Packit a69f91
	log_user 0
Packit a69f91
Packit a69f91
To restore output:
Packit a69f91
Packit a69f91
	log_user 1
Packit a69f91
Packit a69f91
See the Expect man page for more details or page 175 of Exploring
Packit a69f91
Expect for details and examples.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#37. Why does it send back the same string twice?
Packit a69f91
Packit a69f91
From: Don Libes
Packit a69f91
To: yusufg@himalaya.cc.gatech.edu (Yusuf Goolamabbas)
Packit a69f91
Subject: Duplicate pattern matches in Expectk
Packit a69f91
--text follows this line--
Packit a69f91
   Hi, I am trying to do a very simple thing in expectk
Packit a69f91
Packit a69f91
   spawn cat
Packit a69f91
   expect_background -re ".+" {
Packit a69f91
	   send $expect_out(0,string)
Packit a69f91
   }
Packit a69f91
   exp_send "Hello World\n"
Packit a69f91
Packit a69f91
   Now the display in the text widget looks like this
Packit a69f91
   Hello World\r
Packit a69f91
   Hello World\r
Packit a69f91
Packit a69f91
   whereas I was expecting only one line 
Packit a69f91
   Hello World\r
Packit a69f91
Packit a69f91
   Thanks in advance, Yusuf
Packit a69f91
   -- 
Packit a69f91
   Yusuf Goolamabbas                               yusufg@cc.gatech.edu
Packit a69f91
   Graphics, Visualization, & Usability Center     (O) 404.894.8791
Packit a69f91
   College of Computing Georgia Tech          
Packit a69f91
   http://www.cc.gatech.edu/grads/g/Yusuf.Goolamabbas/home.html
Packit a69f91
Packit a69f91
This is correct behavior.  The first "Hello World" is echoed by the
Packit a69f91
terminal driver.  The second is echoed by cat.  This behavior has
Packit a69f91
nothing to do with Expectk (or Expect for that matter).  You can see
Packit a69f91
this same thing if you type to cat interactively.
Packit a69f91
Packit a69f91
% cat
Packit a69f91
Hello World
Packit a69f91
Hello World
Packit a69f91
Packit a69f91
In the example above, I typed "cat" at the shell prompt and pressed
Packit a69f91
return.  Then I entered "Hello World" and pressed return.  Looking at
Packit a69f91
the output I *see* "Hello World" twice even though I only entered it
Packit a69f91
once.
Packit a69f91
Packit a69f91
You can account for this behavior in your patterns.  Alternatively,
Packit a69f91
just turn off the echo.  In your particular case though, it's doing
Packit a69f91
the right thing, showing you the result of an interactive cat just as
Packit a69f91
if you had typed it yourself.
Packit a69f91
Packit a69f91
In practice, this kind of problem doesn't arise - because programs
Packit a69f91
like cat aren't spawned (except in very special situations).  I assume
Packit a69f91
that cat was just something you chose to experiment with.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#38. Why can't I send the line "user@hostname\r"?
Packit a69f91
Packit a69f91
From: libes (Don Libes)
Packit a69f91
To: bt@nadine.hpl.hp.com
Packit a69f91
Subject: Re: [Q] Expect, ftp and '@'
Packit a69f91
Packit a69f91
>   I am attempting to use Expect to perform anonymous ftp gets without
Packit a69f91
>my having to type all the stuff --- I mean, waaaiiiting for the
Packit a69f91
>prompt, entering a-n-o-n-y-m-o-u-s with my fat fingers, and the rest.
Packit a69f91
>
Packit a69f91
>   But I have a probleme: as I set the password to be my e-mail address:
Packit a69f91
>   set password "bt@hplb.hpl.hp.com"
Packit a69f91
Packit a69f91
> the ftp servers seem not to receive neither my login name nor the
Packit a69f91
>at-sign. Some of them do not care, some others say "ok, but don't do
Packit a69f91
>that again", and the last ones throw me off.
Packit a69f91
Packit a69f91
The short answer is to upgrade to Expect 5.20 or later.  If you
Packit a69f91
don't feel like doing this, here's the explanation for older versions
Packit a69f91
of Expect:
Packit a69f91
Packit a69f91
spawn initializes the terminal by using your current parameters and
Packit a69f91
then forces them to be "sane".  Unfortunately, on your system, "sane"
Packit a69f91
says to interpret the "@" as the line-kill character.
Packit a69f91
Packit a69f91
The most sensible thing to do is change "sane" in your Makefile to
Packit a69f91
something that makes sense.  (Since you work at HP, you might also
Packit a69f91
suggest that they modernize stty!)
Packit a69f91
Packit a69f91
Here's an example of a replacement line for the Makefile:
Packit a69f91
Packit a69f91
	STTY = -DDFLT_STTY=\""sane kill ^U"\"
Packit a69f91
Packit a69f91
Other alternatives are: quote the @, or use the -nottyinit flag, or
Packit a69f91
set the stty_init variable.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#39. How do I hide the output of the send command?
Packit a69f91
Packit a69f91
From: tim@mks.com (Timothy D. Prime)
Packit a69f91
Subject: Re: hide the text of expect's send command?
Packit a69f91
Date: 29 Mar 1996 15:41:02 GMT
Packit a69f91
Packit a69f91
In article <khughesDoy1yH.5zo@netcom.com>, Kirby Hughes <khughes@netcom.com> wrote:
Packit a69f91
> I don't want to see (on the screen) the text sent by a "send" command.  Is
Packit a69f91
> there a way to hide it?  "log_user 0" works for text coming back to me, but
Packit a69f91
> doesn't (seem to) work for sending...
Packit a69f91
> 
Packit a69f91
> #!/usr/local/bin/expect --
Packit a69f91
> log_user 0
Packit a69f91
> spawn telnet proxy
Packit a69f91
> expect Command
Packit a69f91
> send "c [lrange $argv 0 1]\n"
Packit a69f91
> log_user 1
Packit a69f91
> interact
Packit a69f91
Packit a69f91
This answer courtesy of Timothy Prime, Mortice Kern Systems (tim@mks.com):
Packit a69f91
Packit a69f91
The output you are seeing wasn't printed by the send command.
Packit a69f91
(I.e., the log_user command is working just fine.)  The output you see
Packit a69f91
is from the interact command.  The interact command found program
Packit a69f91
output and thus wrote it to the terminal so that you could see it.
Packit a69f91
That's what the interact command is supposed to do!
Packit a69f91
Packit a69f91
Although the expanation might take a little thought, the solution is
Packit a69f91
easy.  Simply put an expect command in before the command "log_user 1".
Packit a69f91
Match against the last characters that you wish to suppress.
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#40. Why don't I see pauses between characters sent with send -s?
Packit a69f91
Packit a69f91
From: jcarney@mtl.mit.edu (John C. Carney)
Packit a69f91
Newsgroups: comp.lang.tcl
Packit a69f91
Date: 12 Aug 1996 17:32:54 GMT
Packit a69f91
Organization: Massachvsetts Institvte of Technology
Packit a69f91
Packit a69f91
I am trying to use expect to spawn the kermit program. It then
Packit a69f91
is supposed to dial the modem and procede.
Packit a69f91
Packit a69f91
When I run kermit from the shell, it has no problem dialing the
Packit a69f91
modem. However, when kermit is spawned by expect, it will not dial.
Packit a69f91
Packit a69f91
I thought perhaps the input stream was too fast for kermit and tried
Packit a69f91
send -s. I do see a long delay before the dial message is sent, but it
Packit a69f91
still won't dial. Also, I would expect (no pun) that I would see the
Packit a69f91
characters sent as follows:
Packit a69f91
Packit a69f91
a<pause>t<pause>d<pause>t<pause> ...
Packit a69f91
Packit a69f91
But instead I see:
Packit a69f91
Packit a69f91
<long_pause>atdt ...
Packit a69f91
Packit a69f91
What am I doing wrong?
Packit a69f91
Packit a69f91
Thanks for you help.
Packit a69f91
Packit a69f91
John Carney
Packit a69f91
jcarney@garcon.mit.edu
Packit a69f91
Packit a69f91
The send command doesn't wait for responses.  The echoing you see
Packit a69f91
is from an expect command running after send has run.  At that point,
Packit a69f91
all the characters have been echoed already - thus, you see the long
Packit a69f91
pause (while send is running) and the rush of characters (while expect
Packit a69f91
is running).
Packit a69f91
Packit a69f91
Before you ask, no, it doesn't make sense to have send pause
Packit a69f91
briefly and wait for echoing.  Sometimes there is no echoing.  And
Packit a69f91
sometimes things aren't echoed in an intuitive way.  So how could send
Packit a69f91
possibly know what to wait for and how long?
Packit a69f91
Packit a69f91
The solution is to use the expect background command:
Packit a69f91
   expect_background -re .+
Packit a69f91
Packit a69f91
Just put this after your spawn command and before you start sending
Packit a69f91
things.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#41. Why does "talk" fail with "Who are you?  You have no entry utmp" or
Packit a69f91
	"You don't exist.  Go away"?
Packit a69f91
Packit a69f91
From: libes (Don Libes)
Packit a69f91
To: Will Smith (AC) <william@ritchie.acomp.usf.edu>
Packit a69f91
Subject: Expect
Packit a69f91
Packit a69f91
Will Smith (AC) writes:
Packit a69f91
>Hi there.  I was wondering if you had any ideas to why i am getting
Packit a69f91
>this problem running an Expect script which tries to spawn a talk
Packit a69f91
>process to myself on another machine. Would it have anything to do
Packit a69f91
>with the fact that the executables are NOT installed in /usr/local/bin
Packit a69f91
>or because it wasnt installed by ROOT or what. This is what my Expect
Packit a69f91
>script looks like.
Packit a69f91
>
Packit a69f91
>#! /home/ritchie/ops/william/test/expect -f
Packit a69f91
>
Packit a69f91
>spawn talk william@curiac.acomp
Packit a69f91
>set timeout 200
Packit a69f91
>expect {*established*}
Packit a69f91
>set send_human {.1 .3 1 .05 2}
Packit a69f91
>send -h "This is only a test.. I swear \ Please don't bust me with expect \n  >expect "{*\r*}"
Packit a69f91
>expect "{*\r*}"
Packit a69f91
>exec sleep 5
Packit a69f91
>send -h "Ok, well see ya tomorrow you idiot \n"
Packit a69f91
>exec sleep 3
Packit a69f91
>
Packit a69f91
>The error i get is that it returns this when i run the script.
Packit a69f91
>
Packit a69f91
>  Who are you? You have no entry in /etc/utmp! Aborting...
Packit a69f91
Packit a69f91
On most systems, Expect does not automatically make a utmp entry.  (A
Packit a69f91
utmp entry normally indicates login information which seems kind of
Packit a69f91
pointless for Expect scripts.)  This allows Expect to run non-setuid.
Packit a69f91
Packit a69f91
Normally, this lack of utmp entries doesn't mean much.  However, a few
Packit a69f91
programs actually refuse to run without a utmp entry.  Fortunately,
Packit a69f91
there are workarounds:
Packit a69f91
Packit a69f91
Program-dependent solutions:
Packit a69f91
Packit a69f91
"talk" is the only program I'm aware of that falls into this category.
Packit a69f91
One solution is to get ytalk.  ytalk doesn't have this problem plus it
Packit a69f91
fixes many other bugs in talk, such as being able to communicate with
Packit a69f91
both old and new talk.
Packit a69f91
Packit a69f91
Program-independent solutions:
Packit a69f91
Packit a69f91
Use a program specifically intended to create utmp entries.  Such
Packit a69f91
programs are easy to write or get if you don't have them already.  For
Packit a69f91
instance, sessreg is one which comes with the xdm distribution.  And
Packit a69f91
Solaris uses utmp_update.  I like this approach because it isolates
Packit a69f91
the setuid code in a small single system utility rather than in every
Packit a69f91
program on the system that needs this ability.
Packit a69f91
Packit a69f91
Tod Olson <tao@stone.lib.uchicago.edu> sent in the following
Packit a69f91
example of how to use sessreg.  He says: sessreg works nicely.  Here
Packit a69f91
is a fragment showing how we invoke sessreg on our Linux machines.
Packit a69f91
Note: sessreg must be able to write utmp.  We decided to make utmp
Packit a69f91
work writable, since it's a kinda bogus creature anyhow, rather than
Packit a69f91
make sessreg suid root (or whatever).
Packit a69f91
Packit a69f91
...
Packit a69f91
spawn $shell
Packit a69f91
expect $prompt
Packit a69f91
send "sessreg -w /var/run/utmp -a $user\r"
Packit a69f91
expect $prompt
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#42. Why does . match a newline?
Packit a69f91
Packit a69f91
From: libes (Don Libes)
Packit a69f91
To: xipr@alv.teli.se (Ivan Prochazka)
Packit a69f91
Subject: Why does . match a newline?
Packit a69f91
Ivan Prochazka writes:
Packit a69f91
>
Packit a69f91
>Hello Don.
Packit a69f91
>
Packit a69f91
>In my opinion(and emacs) the regexp-symbol "." stands for all
Packit a69f91
>characters except newline(\n). 
Packit a69f91
>This is not the case in Expect 5.2.
Packit a69f91
Packit a69f91
Yes, there are some packages that follow this convention, but I don't
Packit a69f91
think it is appropriate for Expect.  Unlike emacs, most Expect
Packit a69f91
patterns don't look for full lines - more often they look for prompts
Packit a69f91
which *don't* end with newlines.
Packit a69f91
Packit a69f91
I find that I actually write the [^\n] pattern very rarely.  And
Packit a69f91
if I write it frequently in a script, then the expect itself probably
Packit a69f91
ought to be in a subroutine.
Packit a69f91
Packit a69f91
In fact, the more common line-terminating sequence in Expect is \r\n,
Packit a69f91
so that might make a more likely argument.  In any case, Expect
Packit a69f91
defines . the way POSIX does.  So I feel pretty good about the
Packit a69f91
definition of . being what it is.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#43. Why doesn't Expect kill telnet (or other programs) sometimes?
Packit a69f91
Packit a69f91
From: libes (Don Libes)
Packit a69f91
To: Karl.Sierka@Labyrinth.COM
Packit a69f91
Subject: Re: need help running telnet Expect script from cron on sunos 4.1.3
Packit a69f91
Packit a69f91
karl.sierka@labyrinth.com writes:
Packit a69f91
>       The only problem I am still having with the script I wrote is that
Packit a69f91
>    the telnet does not seem to die on it's own, unless I turn on debugging.
Packit a69f91
Packit a69f91
Actually, Expect doesn't explicitly kill processes at all.  Generally,
Packit a69f91
processes kill themselves after reading EOF on input.  So it just seems
Packit a69f91
like Expect kills all of its children.
Packit a69f91
Packit a69f91
>    I was forced to save the pid of the spawned telnet, and kill it with an
Packit a69f91
>    'exec kill $pid' in a proc that is hopefully called before the script
Packit a69f91
>    exits. This seems to work fine, but it makes me nervous since omnet
Packit a69f91
>    charges for connect time, and leaving a hung telnet lying around could
Packit a69f91
>    get expensive. I warned the rest of the staff so that they will also be
Packit a69f91
>    on the lookout for any possible hung telnets to omnet.
Packit a69f91
Packit a69f91
The problem is that telnet is not recognizing EOF.  (This is quite
Packit a69f91
understandable since real users can't actually generate one from the
Packit a69f91
telnet user interface.)  The solution is to either 1) explicitly drive
Packit a69f91
telnet to kill itself (i.e., a graceful logout) followed by "expect
Packit a69f91
eof" or 2) "exec kill" as you are doing.
Packit a69f91
Packit a69f91
This is described further in Exploring Expect beginning on page 103.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#44. How come I get "ioctl(set): Inappropriate ..., bye recursed"?
Packit a69f91
Packit a69f91
From: libes (Don Libes)
Packit a69f91
To: james@Solbourne.COM (James B. Davis)
Packit a69f91
Subject: How come I get "ioctl(set): Inappropriate ..., bye recursed" ...
Packit a69f91
Date: Tue, 10 Dec 91 10:47:21 MST
Packit a69f91
Packit a69f91
>Every time I ^C out of a Expect script run I get:
Packit a69f91
>
Packit a69f91
>ioctl(set): Inappropriate ioctl for device
Packit a69f91
>bye recursed
Packit a69f91
>
Packit a69f91
>james@solbourne.com
Packit a69f91
Packit a69f91
This answer courtesy of Michael Grant (mgrant@xdr.ncsl.nist.gov):
Packit a69f91
Packit a69f91
You (or whoever installed gcc) forgot to run the fixincludes shell
Packit a69f91
script while installing gcc.  Recompiled gcc with itself, then run the
Packit a69f91
fixincludes script - and the messages will go away.  
Packit a69f91
Packit a69f91
Michael Grant
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#45. How come there's no interact function in the Expect library?
Packit a69f91
Packit a69f91
From: libes (Don Libes)
Packit a69f91
To: Djamal SIMOHAND <djamal@lyohp5.in2p3.fr>
Packit a69f91
Subject: Re: exp_expectl
Packit a69f91
Date: Wed, 3 Jan 96 12:17:01 EST
Packit a69f91
Packit a69f91
Djamal SIMOHAND writes:
Packit a69f91
>I have already used the Expect program to write a script to connect by
Packit a69f91
>telnet on my machine.  Now I made a graphic interface in C and I need
Packit a69f91
>the expect in C in order to have a coherent executable.
Packit a69f91
>
Packit a69f91
>I've already written most of the C already, but the connection is
Packit a69f91
>closed just after my program is finished.  Then I have no opportunity
Packit a69f91
>to work on my machine.  It seems I need of the equivalent of
Packit a69f91
>"interact" in C.  Is there such a function in the C library?
Packit a69f91
>
Packit a69f91
>Thanks for your help,
Packit a69f91
>                                                      Djamal
Packit a69f91
Packit a69f91
No, there is no interact-like function in the C library.  The reason
Packit a69f91
is three-fold:
Packit a69f91
Packit a69f91
1) It is simple enough to write your own.  It's just a loop after
Packit a69f91
all:
Packit a69f91
Packit a69f91
	while 1 {
Packit a69f91
		select/poll()
Packit a69f91
		read()
Packit a69f91
		write()
Packit a69f91
	}
Packit a69f91
Packit a69f91
2) There's no way I could possibly provide all the options you might
Packit a69f91
need.  In Expect, it's not a problem because the environment is very
Packit a69f91
controlled, but in C, it's impossible to control what you might want
Packit a69f91
to do.  For example, you mention that you're embedding your code in a
Packit a69f91
graphics application.  Graphics packages typically have their own
Packit a69f91
event manager, so you wouldn't want a monolithic interact function.
Packit a69f91
Packit a69f91
3) The library is intended for embedding in other applications, where
Packit a69f91
it rarely makes sense to give the user direct control of a spawned
Packit a69f91
process.  That kind of thing makes so much more sense to handle with
Packit a69f91
an Expect script than a C program.  The C library was not intended as
Packit a69f91
a replacement for Expect.  Expect is really the tool of choice for
Packit a69f91
interaction problems, not C.  
Packit a69f91
Packit a69f91
In summary, there's very little payoff for the library to supply an
Packit a69f91
interact function.  A simple one would only satisfy people who should
Packit a69f91
be using Expect anyway - and it's impossible to create one that would
Packit a69f91
do everything that everyone wants.  It's easier just to let people
Packit a69f91
create their own.  
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#46. Can't you make tkterm understand any terminal type?
Packit a69f91
Packit a69f91
From: swig@teleport.com (Scott Swigart)
Packit a69f91
Newsgroups: comp.lang.tcl
Packit a69f91
Date: Tue, 13 Aug 1996 18:50:22 GMT
Packit a69f91
Packit a69f91
I looked at tkterm, and it is promising, but it's missing some
Packit a69f91
critical features.  For one, I need something that understands various
Packit a69f91
terminal types, and can get it's escape sequences from something like
Packit a69f91
termcap or terminfo, instead of having them hard coded.  Also, I
Packit a69f91
question the ability of an Expect script to keep up if it had 50 or so
Packit a69f91
types of escape sequences to parse.  Actual C code would probably have
Packit a69f91
to be created to do the parsing, and if you're going to go that far,
Packit a69f91
why not just create a terminal widget so you could do something like:
Packit a69f91
Packit a69f91
terminal .myterm -type vt220
Packit a69f91
Packit a69f91
which is more along the lines of what I was originally looking for.
Packit a69f91
Packit a69f91
Yes, that would be divine.  But terminal emulators are horribly
Packit a69f91
complex and very little of that complexity can be discerned from the
Packit a69f91
termcap file.  For example, compare xterm's human-readable docs (63k
Packit a69f91
man page + 18k appendix) to its termcap entry (654 bytes).  Now
Packit a69f91
consider the other hundreds of terminals in termcap each with their
Packit a69f91
own weird extensions.  I can't imagine what kind of ".myterm configure"
Packit a69f91
interface you'd present to the user.  What would you allow the user to
Packit a69f91
change?  The nice thing about tkterm is that everything is accessible
Packit a69f91
to the user, but I can't imagine doing that through a widget
Packit a69f91
interface.
Packit a69f91
Packit a69f91
Unfortunately, like everyone else, I don't have the time...
Packit a69f91
Packit a69f91
Me neither.  Call me lazy.
Packit a69f91
Packit a69f91
As an aside, I wonder why you want the ability for a terminal emulator
Packit a69f91
to read termcap/info.  Turns out that it's useless (unless what you
Packit a69f91
are doing is testing termcap itself).  Because if your app is using
Packit a69f91
termcap in the first place, then it doesn't care what terminal type
Packit a69f91
you choose - so why not choose the one that tkterm does?  (And if your
Packit a69f91
app isn't using termcap, then you have the converse problem.)
Packit a69f91
Packit a69f91
Actually, I and several other people did a fair amount of
Packit a69f91
experimentation (i.e., wrote a lot of C code) to do a universal
Packit a69f91
terminal emulator - turns out that it's not possible in a general
Packit a69f91
sense.  To support any terminal type, you are going to be forced to go
Packit a69f91
beyond what termcap/info offers.  I.e., you'll have to handedit the
Packit a69f91
definition or add new ones and/or accept certain limitations.
Packit a69f91
Packit a69f91
After many revisions, Software - Practice & Experience is
Packit a69f91
publishing a paper on tkterm.  The paper includes more insights on the
Packit a69f91
difficulties I've mentioned here.  You can get a draft of the paper
Packit a69f91
at: http://www.cme.nist.gov/msid/pubs/libes96d.ps
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#47. Trapping SIGCHLD causes looping sometimes
Packit a69f91
Packit a69f91
From: Bryan Kramer <bryan.kramer@hydro.on.ca>
Packit a69f91
Sender: kramer@hydro.on.ca
Packit a69f91
Cc: libes@NIST.GOV
Packit a69f91
Subject: Problem with trap in expect on Solaris
Packit a69f91
Date: Tue, 17 Sep 1996 11:09:50 -0400
Packit a69f91
Packit a69f91
I'm getting an infinite loop running the attached script foo.tcl on my
Packit a69f91
solaris machine (Ultra Sparc, SunOS 5.5).  This does not happen when I
Packit a69f91
run the version of the same expect that I compiled on a Sparc 20 with
Packit a69f91
SunOS 4.1.3UI (even though I am running it on the Solaris 5.5. ultra).
Packit a69f91
Packit a69f91
trap {
Packit a69f91
    if {[catch {
Packit a69f91
	puts stderr "CALL TRAP [trap -number] [trap -name]"
Packit a69f91
	wait -i 1
Packit a69f91
    } output]} {
Packit a69f91
	puts stderr "TRAP $output"
Packit a69f91
	return
Packit a69f91
    }
Packit a69f91
    puts "TRAP DONE"
Packit a69f91
} SIGCHLD
Packit a69f91
Packit a69f91
Packit a69f91
if {[catch {exec trivial} msg]} {
Packit a69f91
    puts stderr "Error $msg"
Packit a69f91
}
Packit a69f91
Packit a69f91
Packit a69f91
Please let me know if there is an immediate work around.
Packit a69f91
Packit a69f91
Thanks
Packit a69f91
-- 
Packit a69f91
|Bryan M. Kramer, Ph.D.	      416-592-8865, fax 416-592-8802|
Packit a69f91
|Ontario Hydro, 700 University Avenue, H12-C1               |
Packit a69f91
|Toronto, Ontario, Canada      M5G 1X6			    |
Packit a69f91
B. Kramer Home Page
Packit a69f91
Packit a69f91
I haven't analyzed your script in depth, but this sounds like a
Packit a69f91
problem I've seen before - it's due to an implementation deficiency in
Packit a69f91
Tcl.  The problem is that when an exec'd process finishes, it raises
Packit a69f91
SIGCHLD.  Expect's "wait" sees that it is Tcl's process.
Packit a69f91
Unfortunately, there is no way to wait for one of Tcl's processes and
Packit a69f91
tell Tcl that you've done so, nor is there any way to have Tcl wait
Packit a69f91
itself.  So Expect's wait just returns.  On some systems alas, this
Packit a69f91
just causes SIGCHLD to be reraised.
Packit a69f91
Packit a69f91
The solution is multipart:
Packit a69f91
   1  Tell John he needs to fix this problem.  (I've told him this but he
Packit a69f91
didn't agree with me that it's a problem.)  Tcl needs to provide a new
Packit a69f91
interface - either to clean up its process or to allow extensions to
Packit a69f91
do the wait and pass the status back to Tcl so that it can have it
Packit a69f91
later when needed.
Packit a69f91
   2  Don't call exec while you are trapping SIGCHLD.  Since this is a
Packit a69f91
severe limitation, I recommend you avoid the problem by using
Packit a69f91
"expect_before eof" to effectively trap the same event.  If you're not
Packit a69f91
already using expect, well, call it every so often anyway.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#48. Why do I get "invalid spawn id"?
Packit a69f91
Packit a69f91
Subject: Why do I get "invalid spawn id"
Packit a69f91
In article <53ggqe$hag@hole.sdsu.edu> khumbert@mail.sdsu.edu writes:
Packit a69f91
      I am trying to write a general looping procedure that will handle
Packit a69f91
   many cases that have similar prompt sequences.  The function and one 
Packit a69f91
   call are below.  
Packit a69f91
      The problem is that when the "looping" function is called I get an
Packit a69f91
   "invalid spawn id(5) while executing "expect $exp1 {send -s "$send1}   
Packit a69f91
   timeout  {continue}".  I only have one spawn in the entire program
Packit a69f91
   (a telnet session).  I've tried setting a spawn_id variable for the
Packit a69f91
   telnet spawn and then setting spawn_id to that variable in "looping",
Packit a69f91
   but no dice, same error.
Packit a69f91
Packit a69f91
      Any ideas?  Thanks in advance for any suggestions!!!
Packit a69f91
Packit a69f91
      Kelly Humbert
Packit a69f91
Packit a69f91
   proc looping {exp1 exp2 send1 send2} {
Packit a69f91
      global max_tries  ### 5 ###
Packit a69f91
      set tries 0
Packit a69f91
      set connected 0
Packit a69f91
      set timeout 60
Packit a69f91
Packit a69f91
      while {$tries <= $max_tries && $connected == 0}  {
Packit a69f91
	 incr tries
Packit a69f91
	 expect {
Packit a69f91
	    $exp1   {send -s $send1}
Packit a69f91
	    timeout {continue}
Packit a69f91
	    }
Packit a69f91
	 expect {
Packit a69f91
	    ">? "   {send -s "\n"}
Packit a69f91
	    timeout {continue}
Packit a69f91
	    }
Packit a69f91
	 expect {
Packit a69f91
	    $exp2   {incr connected;send -s $send2}
Packit a69f91
	    timeout {continue}
Packit a69f91
	    } 
Packit a69f91
	}
Packit a69f91
      return $tries
Packit a69f91
   };
Packit a69f91
Packit a69f91
What's going on is that the spawned process has closed the
Packit a69f91
connection.  When Expect detects this, it matches the "eof" pattern,
Packit a69f91
and the spawn id is marked "invalid".  However, you aren't testing for
Packit a69f91
"eof", so the next command in your script finds the invalid spawn id,
Packit a69f91
hence the complaint.
Packit a69f91
Packit a69f91
If you want to find out where the eof is occurring, enable Expect's
Packit a69f91
diagnostic mode - Expect will get very chatty about what it is doing
Packit a69f91
internally.
Packit a69f91
Packit a69f91
You can handle eof in all your expect statements by add a single
Packit a69f91
expect_before/after command to your script.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#49. Could you put a version number in the filename of the Expect archive?
Packit a69f91
Packit a69f91
From: "Nelson H. F. Beebe" <beebe@math.utah.edu>
Packit a69f91
Date: Mon, 23 Dec 1996 08:46:57 -0700 (MST)
Packit a69f91
Packit a69f91
It would be helpful for the expect distribution to contain its version
Packit a69f91
number, e.g. expect-5.21.6.tar.gz; I had an earlier version called
Packit a69f91
5.21, and it took some diffing to verify that the expect.tar.gz I
Packit a69f91
fetched from ftp://ftp.cme.nist.gov/pub/subject/expect/expect.tar.gz
Packit a69f91
really was newer.
Packit a69f91
Packit a69f91
I don't name the file with a version number because I make new
Packit a69f91
distributions so frequently.  I realize that many other distributions
Packit a69f91
include version numbers in them, but constantly changing filenames
Packit a69f91
really annoys the heck out of people.  I've been packaging Expect this
Packit a69f91
way for five years and I've only gotten this question twice before.
Packit a69f91
In contrast, I'm responsible for a number of other files on our ftp
Packit a69f91
server that do occasionally change names, and I get no end of
Packit a69f91
questions from people about where such and such a file has gone or why
Packit a69f91
their ftp request fails.
Packit a69f91
Packit a69f91
So that people don't have to download the distribution only to find
Packit a69f91
it hasn't changed, there is a HISTORY file in the distribution
Packit a69f91
directory.  It's relatively short and has the latest version number at
Packit a69f91
the top (with any changes listed immediately after).
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#50. Why does Expect work as root, but say "out of ptys" when run as myself?
Packit a69f91
Packit a69f91
Expect works fine as root, but when I run it as myself it says "out of
Packit a69f91
ptys" (which I know isn't true).  Any ideas?
Packit a69f91
Packit a69f91
Sounds like a misconfiguration problem on your system.  For
Packit a69f91
example, once I saw this on a Digital system where the system
Packit a69f91
administrator had decided to remove setuid from all programs ("I heard
Packit a69f91
that setuid is a security risk, right?").  On that particular system,
Packit a69f91
Expect uses a system library function that internally calls an
Packit a69f91
external program chgpt which exists solely for the purpose of managing
Packit a69f91
ptys.  Needless to say, it must be setuid.  Unfortunately, the library
Packit a69f91
function doesn't do enough error checking, and there's no way for Expect
Packit a69f91
to know that, so there's nothing I can do to give a better diagnostic
Packit a69f91
explaining how your system is misconfigured.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#51. Why does spawn fail with "sync byte ...."?
Packit a69f91
Packit a69f91
When I spawned a process using Expect, I got the following
Packit a69f91
message:
Packit a69f91
Packit a69f91
parent: sync byte read: bad file number
Packit a69f91
child: sync byte write: bad file number
Packit a69f91
Packit a69f91
This is one of these "should not happen" errors.  For example, the
Packit a69f91
following question in this FAQ mentions that it could be the fault of
Packit a69f91
the C library.  Another possibility is that you've run out of some
Packit a69f91
system resource (file descriptors).  The most likely reason is that
Packit a69f91
you're calling spawn in a loop and have neglected to call close and
Packit a69f91
wait.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#52. Why does Expect fail on RedHat 5.0?
Packit a69f91
Packit a69f91
Lots of people have reported the following error from Expect on
Packit a69f91
RedHat 5.0:
Packit a69f91
Packit a69f91
failed to get controlling terminal using TIOCSCTTY
Packit a69f91
parent sync byte write: broken pipe
Packit a69f91
Packit a69f91
Martin Bly <ussc@star.rl.ac.uk> reports that:
Packit a69f91
Packit a69f91
The fault is/was in the GNU libc (aka glibc) provided by Red Hat
Packit a69f91
Software.  Our sysadmin updated the version of the C libraries we have
Packit a69f91
installed and both problems have vanished - in the case of the expect
Packit a69f91
test, without a rebuild.
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#53. Why does Expect fail on RedHat 5.1?
Packit a69f91
Packit a69f91
People have reported the following error from Expect on RedHat
Packit a69f91
5.1:
Packit a69f91
Packit a69f91
failed to get controlling terminal using TIOCSCTTY
Packit a69f91
parent sync byte write: broken pipe
Packit a69f91
Packit a69f91
If there are any people
Packit a69f91
who have some debugging experience and can reproduce that error on
Packit a69f91
RedHat 5.1, read on:
Packit a69f91
Packit a69f91
First look in the man page (or perhaps diff the 5.1 and pre-5.1 man
Packit a69f91
pages) governing TIOCSTTY and let me know what you find.
Packit a69f91
Alternatively look at the source to xterm (or some other program that
Packit a69f91
must allocate a pty) and see how it is allocating a pty.
Packit a69f91
Packit a69f91
If anyone else is wondering if the problem has been fixed by the time
Packit a69f91
you read this, just check the FAQ again.  I'll update it as soon as
Packit a69f91
the problem has been successfully diagnosed.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
#54. Is Expect Y2K compliant?
Packit a69f91
Packit a69f91
The short answer is: Yes, if you're using a modern version of Tcl
Packit a69f91
(7.6p2 or later).
Packit a69f91
Packit a69f91
Longer answer: Tcl 7.5 and 7.6p0/1 had bugs that caused them to be
Packit a69f91
noncompliant with regard to how POSIX defines 2-character years.  If
Packit a69f91
your scripts use 2-character years, you should upgrade to a modern
Packit a69f91
version of Tcl.  If your scripts use 4-character years, than you have
Packit a69f91
nothing to worry about.
Packit a69f91
Packit a69f91
Don
Packit a69f91
Packit a69f91
======================================================================
Packit a69f91
Packit a69f91
Packit a69f91
Names of companies and products, and links to commercial pages are
Packit a69f91
provided in order to adequately specify procedures and equipment used.
Packit a69f91
In no case does such identification imply recommendation or
Packit a69f91
endorsement by the National Institute of Standards and Technology, nor
Packit a69f91
does it imply that the products are necessarily the best available for
Packit a69f91
the purpose.
Packit a69f91
Packit a69f91
Last edited: Tue Sep 22 17:52:23 EDT 1998 by Don Libes