OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [expect/] [FAQ] - Blame information for rev 1778

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
Expect FAQ (Frequently Asked Questions)
2
 
3
An HTML version of this FAQ can be found in http://elib.cme.nist.gov/pub/expect/FAQ.html
4
 
5
This FAQ lists common questions, usually about subjects that didn't
6
fit well in the book for one reason or another (or weren't
7
indexed sufficiently well so that people can't find the answers easily
8
enough).  In some cases, I've left the original questions.  I suppose
9
I could've stripped off the headers, but it seems more realistic to
10
see actual people who've asked the questions.  Thanks to everyone who
11
asked.
12
 
13
The man page and the papers listed in the README file should
14
also be consulted for highly technical or philosophical discussion of
15
the implementation, design, and practical application of Expect.
16
 
17
Don
18
 
19
======================================================================
20
 
21
                Here is the list of questions.  You can search for the corresponding
22
                answer by searching for the question number.  For example searching
23
                for "#3." will get you that answer.
24
 
25
 
26
**** General ****
27
 
28
#1. I keep hearing about Expect.  So what is it?
29
#2. How do you pronounce "Ousterhout" anyway?  (Or "Libes" for that matter?)
30
 
31
#3. Why should I learn yet another language (Tcl) instead of
32
writing my interaction in .
33
#4. What about Perl?
34
#5. Do we need to pay or ask for permission to distribute Expect?
35
#6. Since Expect is free, can we give you a gift?
36
#7. Are there any hidden dangers in using Expect?
37
 
38
**** Book, newsgroup, FAQ, README, ... ****
39
 
40
#8. Why is this FAQ so short?
41
#9. The FAQ background makes the FAQ hard to read.
42
#10. Why isn't there an Expect mailing list?
43
#11. Why isn't overlay covered in Exploring Expect?
44
#12. Is the front cover of your book a self portrait (ha ha)?
45
#13. How are your daughter's kidneys?
46
#14. Are you going to have a book signing?
47
#15. How many books have you sold?
48
#16. I just want to tell you how much I like your book!
49
#17. Why don't the examples in your USENIX papers work?
50
#18. Can you put the examples in your book into an anonymous ftp site?
51
#19. Do you have ideas for more articles on Expect?
52
 
53
**** Can Expect do this? ****
54
 
55
#20. Can Expect automatically generate a script from watching a session?
56
#21. Can Expect understand screen-oriented (Curses) programs?
57
#22. Can Expect be run as a CGI script?
58
#23. Can Expect be run from cron?
59
 
60
**** Compilation or porting questions ****
61
 
62
#24. Why can't I compile Expect with Tcl 7.5?
63
#25. Why does Expect need to be setuid root on Cray?
64
#26. Does Expect run on VMS?
65
#27. Is it possible to use Expect and TclX together?
66
#28. Is it possible to use Expect and  together?
67
#29. Why does configure complain about "cross-compiling"?
68
#30. make/configure seems to be looping endlessly
69
#31. Compile fails with: Don't know how to make pty_.c
70
#32. Does Expect run on MSDOS, Win95, WinNT, MacOS, etc...
71
 
72
**** Other... ****
73
 
74
#33. Is it possible to prevent Expect from printing out its interactions?
75
#34. Why does it send back the same string twice?
76
#35. Why can't I send the line "user@hostname\r"?
77
#36. How do I hide the output of the send command?
78
#37. Why does "talk" fail with "Who are you?  You have no entry utmp" or
79
        "You don't exist.  Go away".
80
#38. Why does . match a newline?
81
#39. Why doesn't Expect kill telnet (or other programs) sometimes?
82
#40. How come I get "ioctl(set): Inappropriate ..., bye recursed" ...
83
#41. How come there's no interact function in the Expect library?
84
 
85
 
86
*
87
* Questions and Answers
88
*
89
 
90
 
91
 
92
**** General ****
93
 
94
 
95
#1. I keep hearing about Expect.  So what is it?
96
 
97
From: libes (Don Libes)
98
To: Charles Hymes 
99
Subject: I keep hearing about Expect.  So what is it?
100
 
101
Charles Hymes writes:
102
>
103
>So, what is Expect?
104
 
105
Expect is a tool primarily for automating interactive applications
106
such as telnet, ftp, passwd, fsck, rlogin, tip, etc.  Expect really
107
makes this stuff trivial.  Expect is also useful for testing these
108
same applications.  Expect is described in many books, articles,
109
papers, and FAQs.  There is an entire book on it available from
110
O'Reilly.
111
 
112
You can ftp Expect from ftp.cme.nist.gov as pub/expect/expect.tar.Z or ...gz
113
 
114
Expect requires Tcl.  If you don't already have Tcl, you can get it
115
in the same directory (above) as pub/expect/tcl.tar.Z or ...gz.
116
 
117
Expect is free and in the public domain.
118
 
119
Don
120
 
121
======================================================================
122
 
123
#2. How do you pronounce "Ousterhout" anyway?  (Or "Libes" for that matter?)
124
 
125
 
126
From: ouster@sprite.Berkeley.EDU (John Ousterhout)
127
To: libes@cme.nist.gov
128
Subject: Re: pronunciation?
129
Date: Tue, 29 May 90 21:26:10 PDT
130
 
131
Those of us in the family pronounce it "OH-stir-howt", where the
132
first syllable rhymes with "low", the second with "purr", and the
133
third with "doubt".  Unfortunately this isn't the correct Dutch
134
pronounciation for a name spelled this way (someplace along
135
the line it got misspelled:  it was originally "Oosterhout"), nor
136
is it what you'd guess if you use common sense.  So, we've gotten
137
used to responding to almost anything.
138
 
139
                                        -John-
140
 
141
I suppose I should say something in kind.  "Libes" is pronounced
142
"Lee-bis" with stress on the first syllable.  Like John though, I've
143
gotten used to responding to anything close.
144
 
145
By the way, notice the date on this message.  I had only written
146
the first cut of Expect four months earlier.  I asked John how to
147
pronounce his name because I had already got a paper accepted into
148
USENIX and needed to be able to say his name correctly while giving
149
the talk!
150
 
151
Don
152
 
153
======================================================================
154
 
155
#3. Why should I learn yet another language (Tcl) instead of
156
writing my interaction in .
157
 
158
From: libes (Don Libes)
159
To: Aamod Sane 
160
Subject: Re: Expect, Tcl, programmed dialogue etc.
161
Date: Mon, 2 Sep 91 15:47:14 EDT
162
 
163
>       >>A friend told me about "Expect". But then, I have to know the
164
>       >>idiocies of "tcl". I would like to know if there is an alternative
165
>       >>to Expect that is also useful in other places, so that I do not
166
>       >>have to spend time getting used to tcl for just this one tool.
167
>
168
>       Your reasoning is shortsighted.  Tcl is a language that can be used in
169
>       other applications.  It won't be a waste of your time to learn it.
170
>
171
>I have nothing against tcl as such.
172
>The reluctance to learn it comes mainly from the feeling that half my
173
>life seems to be spent learning new languages that differ very little
174
>from existing ones, and differ in annoying little details at that.
175
>To add to the misery, every implementation has its own
176
>idiosyncracies...:-(
177
 
178
Ironically, Tcl was written specifically to halt this very problem.
179
 
180
The author recognized that every utility seems to have its own
181
idiosyncratic .rc file or programming language.  Tcl was designed as a
182
general-purpose language that could be included with any utility, to
183
avoid having everyone hack up their own new language.
184
 
185
 In this context, your statements do Tcl a great disservice.
186
 
187
Don
188
 
189
======================================================================
190
 
191
#4. What about Perl?
192
 
193
From: libes (Don Libes)
194
To: Joe McGuckin 
195
Subject: Re: Need Perl examples
196
Date: Sun, 22 Jan 95 20:17:39 EST
197
 
198
Joe McGuckin writes:
199
>
200
>Yeah, I've scanned through your book a couple of times in the last
201
>week, trying to make up my mind if I should buy it.
202
 
203
I spent three years writing it - so I'm glad to hear you're spending a
204
little time considering its merit!
205
 
206
>Pro:
207
>   Looks like implementing some sort of telnet daemon would be trivial.
208
 
209
Once you see it as an Expect script, you'll realize how trivial
210
these things can really be.
211
 
212
>Con:
213
>   Yet another language to learn. I know perl reasonably well & would
214
>   like to stick with it.
215
 
216
Good point.  While I'm not a Perl guru, I've used it quite a bit
217
and it's nice for many things.  But I wouldn't have bothered writing
218
Expect in the first place if I thought Perl was ideal.  And many Perl
219
experts agree - I know a lot of them who call out to Expect scripts
220
rather than do this stuff in Perl - it's that much easier with Expect.
221
Expect is also much more mature.  It's portable, stable, robust, and
222
it's fully documented - with lots of examples and a complete tutorial,
223
too.
224
 
225
In response to someone complaining about how difficult it was to do
226
something in Perl, Larry Wall once remarked: "The key to using
227
Perl is to focus on its strengths and avoid its weaknesses."  That
228
definitely applies here.
229
 
230
Even if you do proceed with Perl, you will find the book
231
helpful.  Automating interactive applications has unique pitfalls to
232
it and many of the descriptions and solutions in the book transcend
233
the choice of language that you use to implement them.
234
 
235
Don
236
 
237
======================================================================
238
 
239
#5. Do we need to pay or ask for permission to distribute Expect?
240
 
241
From: libes (Don Libes)
242
To: Mohammad Reza Jahanbin 
243
Subject: Copyright Question.
244
Date: Tue, 26 Jan 93 23:46:24 EST
245
 
246
Mohammad Reza Jahanbin writes:
247
>Before anything let me thank you on behalf of ComputeVision R&D for
248
>putting so much effort into Expect. Part of CV has been using Expect
249
>for the past two years or so to build variety of tools including an
250
>automated testbed for a product.
251
>
252
>CV is currently considering shipping the automated testbed to some of its
253
>retailers, to enable them to perform their own tests before distributing
254
>the product.
255
>
256
>The Question is, are we allowed to ship Expect? Do we need to ask
257
>anyone for permission? Do we need to say or write anything in the
258
>documentation? Do we need to pay for it?
259
>
260
>I have not been able to find any copyright (or indeed copyleft) notices
261
>in the usual Expect distribution. Would you be able to clarify our position.
262
 
263
Sorry to delay in responding.  I sent your request to my management
264
and they had to discuss it (if they didn't, there would be no reason
265
to pay them).  While they continue to discuss it, I can tell you
266
informally the gist of what they will eventually say:
267
 
268
You are allowed to do just about anything with Expect.  You can even
269
sell it.  You need not ask our permission.  You need not pay for it.
270
(It is my understanding that your tax dollars, in effect, already have
271
paid for it.)
272
 
273
You should not claim that you wrote it (since this would be a lie), nor
274
should you attempt to copyright it (this would be fruitless as it is a
275
work of the US government and therefore not subject to copyright).
276
 
277
NIST would appreciate any credit you can give for this work.  One line
278
may suffice (as far as I'm concerned) although there should be
279
something to the effect that this software was produced for research
280
purposes.  No warantee, guarantee, or liability is implied.
281
 
282
My management is always interested in feedback on our work.  If you
283
would like to send letters of praise describing how Expect has helped
284
your business, we would be delighted.  Letters (on letterhead please)
285
are strong evidence used by policy makers when deciding where every
286
dollar goes.  If you want to send these letters to NIST directly, you
287
may send them to the following individuals:
288
 
289
Arati Prabahkar, Director
290
NIST
291
Admin Bldg, Rm A-1134
292
Gaithersburg, MD 20899
293
 
294
Ric Jackson, Manufacturing Engineering Laboratory
295
NIST
296
Bldg 220, Rm B-322
297
Gaithersburg, MD 20899
298
 
299
Howard Bloom, Manufacturing Systems Integration Division
300
NIST
301
Bldg 220, Rm A-127
302
Gaithersburg, MD 20899
303
 
304
Steve Ray, Manufacturing Collaboration Technologies Group
305
NIST
306
Bldg 220, Rm A-127
307
Gaithersburg, MD 20899
308
 
309
In case you're wondering about the uninformative titles, Arati Prabahkar is the
310
director of all of NIST (about 3000 people) and Steve Ray (way down there
311
at the bottom) is my immediate supervisor (and of 10 other very lucky people).
312
 
313
I hope this has answered your questions.  Let me know if you have
314
further questions.
315
 
316
Don
317
 
318
======================================================================
319
 
320
#6. Since Expect is free, can we give you a gift?
321
 
322
This is not an actual letter but represents the gist of several
323
that I've received.
324
 
325
>>>Expect has saved us many thousands of dollars.  We'd like to send
326
>>>you a free copy of our product.
327
>>
328
>>Thanks, but please don't.  As a federal employee, I'm not
329
>>allowed to accept gifts of any significant value.
330
>
331
>But, what if it is for personal use (like at home)? I assume
332
>that would be okay.
333
 
334
It doesn't matter (much).  What the rules address is whether a gift
335
might cause me to make an official decision differently.  This is
336
especially a concern because I may very well have to decide whether or
337
not to buy products from your company in the future.
338
 
339
There is a clause that says "you may accept gifts from friends,
340
regardless of value ... but you should be careful to avoid accepting
341
gifts which may create an appearance of impropriety, even if permitted
342
as an exception to the gift rules."
343
 
344
I'm still permitted to accept small token gifts, such as a t-shirt
345
or reasonably-priced dinner (under $20 per gift to a maximum of $50
346
per year from any person or company) - so things are not totally
347
ridiculous.  Although the precise values in the gift rules seem rather
348
arbitrary, I actually like the gift rules.  They stop a lot of the
349
nonsense that used to go on involving gifts.
350
 
351
Don
352
 
353
======================================================================
354
 
355
#7. Are there any hidden dangers in using Expect?
356
 
357
From: Charlton Henry Harrison 
358
To: libes@NIST.GOV
359
Date: Fri, 27 Jan 1995 23:30:56 -0600
360
 
361
>>>Dear Don:
362
>>>
363
>>>     I've been a fan of Expect ever since I first learned of UNIX back
364
>>>in late '93. I'm young and don't have my CS degree just yet, but I worked
365
>>>a while back at Texas Instruments in their Telecom Customer Support dept.
366
>>>I started in late '93 (and hence, that's where I first started exploring
367
>>>the UNIX environment) and immediately forsaw the need of automating a lot
368
>>>of my redundant and mindless duties, but I didn't know how since we were
369
>>>working over a heterogeneous LAN with multiple OSs.
370
>>>     Then I found out about Expect. I automated everything! My boss didn't
371
>>>like hearing that I was working on something else in order to get out of
372
>>>work, and I got tired of explaining it to him.
373
>>>     Although I accomplished all the aspects of my duties, I was infamous
374
>>>for being the laziest person at work, and it showed (I made my job SO easy).
375
>>>I got a new boss after a while, and he hated me from the start and fired
376
>>>me soon after. Oh well, I guess my mentality didn't click with theirs.
377
>>>     There are a lot of people like that: they believe life is putting
378
>>>in a hard day's work to get by. I hate that.
379
>>>     So the point is, thank you for the wonderful 'Expect'. I bought
380
>>>your book and now I have the most recent version of it on my Linux system
381
>>>at home. Needless to say I'm looking for another job, though.
382
>>>
383
>>>                                                     Charlton
384
>>>
385
>> Thanks very much for your nice letter.  Sorry to hear about your
386
>> automating yourself out of a job.  Actually, I think most computer
387
>> scientists have to face this dilemma.  In some ways, it's a
388
>> self-defeating occupation.
389
>>
390
>> Don
391
>
392
>Yeah, I'd be interested in hearing if you have a personal philosophy on
393
>how to handle this kind of thing. I plan on pursuing a career in Artificial
394
>Intelligence for similar reason of making life easier for everyone (me
395
>in particular!)  What the future holds in this category is a great
396
>mystery.
397
 
398
I'm glad you asked.  My personal philosophy on this kind of thing is:
399
Find someone really rich and marry them.
400
 
401
Don
402
 
403
======================================================================
404
 
405
**** Book, newsgroup, FAQ, README, ... ****
406
 
407
 
408
#8. Why is this FAQ so short?
409
 
410
From: libes (Don Libes)
411
To: Wade Holst 
412
Subject: Expect question
413
 
414
Wade Holst writes:
415
>
416
> 1) Is there a more up-to-date version of the FAQ than what
417
>    comes with expect-5.5?  (For such a useful application, I
418
>    would expect more than 12 questions).
419
 
420
I know that a lot of other packages have *huge* FAQs but I
421
have always believed that this is an indication that their regular
422
documentation sucks.  As questions arise that are not addressed well
423
by the original docs, the docs themselves should be fixed rather than
424
new ones created.
425
 
426
In contrast, I believe that an FAQ should literally be a list of
427
frequently asked questions and little else.  An FAQ should not be a
428
replacement for good documentation.
429
 
430
In that sense, I have tried to use this FAQ as a second place to
431
look rather than a first place.  The place you should always look
432
first is Exploring Expect.  At over 600 pages, the book is very
433
comprehensive, well-organized, and includes three indices and two
434
tables-of-contents to make it very easy to find what you want to know.
435
 
436
The book was not a rush job.  During the three years I spent
437
writing it, virtually every question I was asked became incorporated
438
as subject material for the book.  I wanted to make sure that the book
439
wouldn't need much of an FAQ!
440
 
441
It would not make sense to try and distill the entire book into an
442
FAQ (that is actually comprehensive rather that truly frequently asked
443
questions).  There's simply too much material there.
444
 
445
So this FAQ is short.  It really tries to stick just to *truly*
446
frequently asked questions.
447
 
448
Don
449
 
450
======================================================================
451
 
452
#9. The FAQ background makes the FAQ hard to read.
453
 
454
To: bonneau@mudd.csap.af.mil (Allen Bonneau)
455
Subject: FAQ background colors
456
Date: Wed, 10 Apr 96 10:24:52 EDT
457
 
458
Allen Bonneau writes:
459
>... the white and gray background makes the FAQ difficult to read.
460
 
461
It's not white and gray.  It's several very close shades of gray.
462
It's supposed to be very subtle.  Sounds like you have your browser in
463
a mode where it is mishandling colors.  Try turning on dithering.
464
 
465
Don
466
 
467
======================================================================
468
 
469
#10. Why isn't there an Expect mailing list?
470
 
471
From: libes (Don Libes)
472
To: dclark@nas.nasa.gov (David R. Clark)
473
Subject: Mailing list for Expect
474
Date: Mon, 23 Sep 91 18:21:28 EDT
475
 
476
>Would be nice if their were an Expect mailing list.  I would use it more
477
>often, and be made aware of other users.
478
 
479
Perhaps I'm too myopic, but I don't see the need for it.  Most of
480
the questions about Expect posted to Usenet every day can be found in
481
the various FAQs or in the book, so it's pretty easy getting
482
answers to them.
483
 
484
For one reason or another (occasionally a bug fix, but often, just
485
adding a neat example), I update Expect every couple of weeks.
486
Personally, I'd hate being on the other end of something like this.
487
Who needs patches every two weeks for problems that are likely not
488
even relevant to you?  (Most patches these days are either extremely
489
esoteric or are related to porting Expect to some unusual machine.)
490
 
491
>It would be helpful, too, if this served as an area for swapping programs.
492
>Many of the things that I want to do are done by others already.
493
 
494
Send me things that you'd like to distribute.  I can include it
495
with Expect or put it in a publicly accessible directory so other
496
people can get it.  I'm also willing to list links in Expect's home
497
page to other web pages about projects that use Expect.
498
 
499
There is a Tcl newsgroup, comp.lang.tcl, which many Expect users
500
read.  It's pretty good for asking questions about Tcl, and many of
501
the readers use Expect so Expect questions are encouraged.  The
502
newsgroup is gatewayed to a mailing list (tcl@sprite.berkeley.edu)
503
which is further described in the Tcl documentation.
504
 
505
Don
506
 
507
======================================================================
508
 
509
#11. Why isn't overlay covered in Exploring Expect?
510
 
511
From: libes (Don Libes)
512
To: spaf@cs.purdue.edu
513
Subject: Your book
514
 
515
Gene Spafford writes:
516
>I'm curious as to why the "overlay" command is not mentioned anywhere
517
>in the book.  Is that a recent addition?  A deprecated feature?  I
518
>ended up using it in one of my scripts....
519
 
520
The overlay command has been in Expect for a long time.  In all that
521
time no one has ever asked me about it and I have never used it.
522
Well, I used it once but I really didn't like the result, and so I
523
rewrote the script to not use it.  I left the overlay command in
524
Expect because it seemed like an interesting idea, but I never really
525
finished it - in the sense that I believe it needs some more options
526
and controls.  In comparison, the interact command is very flexible
527
and makes the need for overlay pretty moot.
528
 
529
Don
530
 
531
======================================================================
532
 
533
#12. Is the front cover of your book a self portrait (ha ha)?
534
 
535
From: libes (Don Libes)
536
To: pkinz@cougar.tandem.com (kinzelman_paul)
537
Subject: the cover?
538
 
539
kinzelman paul writes:
540
>The book finally came in. I tried to buy 4 copies but they had only 2
541
>left and they came in last Saturday. Move over Stephen King! :-)
542
 
543
4 copies!?  Wow.  That's more than my mother bought!
544
 
545
>I was discussing your book with somebody who stopped in and we began
546
>to speculate about the monkey on the cover. I don't suppose it's a
547
>self portrait? :-)
548
 
549
There is some real humor here.  There seems to be considerable
550
debate over what the creature is!  The colophon at the end of
551
the book says that it is a chimpanzee.  I like that idea much more
552
than a monkey which is what it looks like to me.  My wife, who has a
553
degree in zoology, explained to me that chimps are actually the second
554
smartest of primates (humans are the smartest).  Chimps are very
555
intelligent and can do many things (but not everything) that humans
556
do.  Perfect for describing Expect.  Anyway, she says I should be
557
honored to have it grace the book cover - even in theory.
558
 
559
I remarked to Edie (the cover designer at O'Reilly) that even though
560
the cover was nice looking, everyone was going to stare at it and say,
561
"Gee, but it looks like a monkey."  She replied "The purpose of the
562
cover is just to get people to pick the book up. This cover will do
563
that. Don't worry. If you get any rude comments from anyone, at least
564
you know they are paying attention."
565
 
566
[After being inundated by people pointing out that the animal
567
really is a monkey, O'Reilly subsequently decided to acquiesce and has
568
changed the colophon to admit that yes it is a rhesus monkey.
569
Evidentally, the book from which O'Reilly has been taking those
570
pictures from was wrong on this one.]
571
 
572
Don
573
 
574
======================================================================
575
 
576
#13. How are your daughter's kidneys?
577
 
578
From: libes
579
To: olav@emerson.physics.ubc.ca
580
Subject: How are your daughter's kidneys?
581
B. Olav Anderson writes:
582
>Don,
583
>
584
>I bought your book regarding expect and it's great and so is Expect.
585
>
586
>P.S. How's your daughters kidneys? I hope the're well hydrated :-)
587
 
588
In retrospect, I probably should have said that her "diapers" were
589
what was well-hydrated.  Glad to see that you found something in the
590
book worth reading!
591
 
592
Don
593
 
594
======================================================================
595
 
596
#14. Are you going to have a book signing?
597
 
598
From: libes (Don Libes)
599
To: Josef Sachs 
600
Subject: Expect
601
 
602
Josef Sachs writes:
603
>Do you have any book-signing sessions planned?
604
 
605
That's very ego-boosting to contemplate but I doubt that my name
606
is enough to draw the kind of crowd that would make it worthwhile.
607
I'll leave that kind of thing to Howard Stern.  Anyway, I have a
608
full-time job working for the government.  I doubt they would take too
609
kindly to me taking time off for self-aggrandizing.  (They weren't
610
particularly encouraging to have me write a book in the first place -
611
as you'll read in the Preface.)
612
 
613
I've written a couple of other books and people have mailed me those
614
for signatures.  (One guy sent me an entire box of books for
615
signatures - he was giving them to friends as Christmas gifts.)  If
616
you're similarly inclined, my address is in Expect's README file.  Or
617
if you're ever in my neck of the woods, feel free to stop by for a
618
chat (and bring your copy).
619
 
620
Don
621
 
622
======================================================================
623
 
624
#15. How many books have you sold?
625
 
626
From: Don Libes
627
To: Thomas Ragland 
628
Subject: Re: AIX smit automation
629
In-Reply-To: <199601092106.VAA19276@bugsy.aa.ans.net>
630
References: <199601092106.VAA19276@bugsy.aa.ans.net>
631
--text follows this line--
632
Thomas Ragland writes:
633
>  btw approximately how many books were sold?  I just bought
634
>  it and it is quite helpful.  Once again, thanks.
635
>
636
>Thomas
637
 
638
Glad you liked the book.  Sorry to disappoint you but I have no
639
idea about how many have been sold.  (I made my mother buy a couple,
640
so I know it's a positive number.)  Believe it or not, I try *not*
641
to pay attention to that type of thing.  I did with my first book
642
and was very disappointed.  (It sold well but it didn't earn that
643
first million that I was dreaming about...)  I've learned that I don't
644
write to sell books or make money.  If I did, I'd be better off
645
writing "Yet Another Book on HTML" or a romance novel.  No, the
646
real reason that I write is - I enjoy it.
647
 
648
Don
649
 
650
======================================================================
651
 
652
#16. I just want to tell you how much I like your book!
653
 
654
To: Joe Pasko 
655
Subject: Re: ***Expect spawn questions*****
656
Date: Thu, 15 Feb 96 14:52:23 EST
657
Joe Pasko writes:
658
>
659
>Thanks Don,
660
>
661
>I just took your advice and it was the tty settings. Thanks a bunch !
662
>
663
>As a side note: Great book !! It's the best howto for tcl-type stuff
664
>that I've seen around.
665
 
666
Thanks for the kind words.  But don't tell me (gee, I already like my
667
book!) - post your opinion to a newsgroup and send a review to a
668
magazine.  I regret that many Tcl users don't pick up the book simply
669
because they think it isn't of any use to the general Tcl user - which
670
of course isn't true.
671
 
672
Don
673
 
674
======================================================================
675
 
676
#17. Why don't the examples in your USENIX papers work?
677
 
678
From: libes (Don Libes)
679
To: Will Smith (AC) 
680
Subject: Expect
681
 
682
Will Smith (AC) writes:
683
>I just entered some scripts from a USENIX paper that my boss had.  I get
684
>errors about my quotes in the script.  Also, it doesn't seem to know
685
>about expect_match.  Thanks in advance for any insight you could offer.
686
 
687
The USENIX papers are old and out-of-date as far as quoting goes.  A
688
couple years ago, I cleaned up and simplified this aspect of Expect.
689
Similarly, expect_out is now where the results of expect's pattern
690
matching are saved.
691
 
692
The man page is always the best reference on what Expect currently
693
supports.  Alternatively, you can read the CHANGES files.  These files
694
document the changes from one major version to another.
695
 
696
Don
697
 
698
======================================================================
699
 
700
#18. Can you put the examples in your book into an anonymous ftp site?
701
 
702
From: libes (Don Libes)
703
To: pren@cs.umass.edu
704
Subject: Examples in your book "Exploring Expect"
705
 
706
Peifong Ren writes:
707
>
708
>Hi,
709
>
710
>I bought your book "Exploring Expect" from O'Reilly.
711
>I wonder can you put the eamples in your book into an anonymous ftp
712
>site?
713
 
714
All of the substantive examples come with recent versions of Expect.
715
Just look in the example directory.
716
 
717
The remaining 50 or so examples are short enough that typing them
718
in only takes a minute or two.  If I put them online, you'd spend more
719
time looking for them (reading my online catalog, figuring out what
720
the online descriptions meant, mapping them back to the file, etc.)
721
then it would take to type them in.  And since you're likely to want
722
to change the examples anyway, there's nothing to be gained for short
723
ones.
724
 
725
Don
726
 
727
======================================================================
728
 
729
#19. Do you have ideas for more articles on Expect?
730
 
731
From: libes (Don Libes)
732
To: faught@zeppelin.convex.com (Danny R. Faught)
733
Cc: libes
734
Subject: Re: SQA Quarterly articles
735
Date: Thu, 21 Dec 95 13:31:01 EST
736
 
737
Danny R. Faught writes:
738
>I just arranged to write an article on automating interactive
739
>processes for an issue early next year.  You have so many good pieces
740
>on expect out there, it's going to be hard to add anything original.
741
 
742
One thing I've never written is a good mini-tutorial.  Magazine
743
editors love these types of pieces and there's certainly a need for
744
it.  So I'd encourage that type of article.
745
 
746
Another possibility is an article on how you or your colleagues
747
personally applied Expect to solve your particular problem. Application-
748
oriented papers are the kind that necessarily have to be written by
749
people in the field who are applying the technology.  People love this
750
kind of practical paper.  For example, a good paper might be "Writing
751
a pager".  This is a nice topic because you can start with a simple
752
5-line script that solves the problem and then show progressive
753
refinements that handle different twists on the same problem.  (And
754
"how to write a pager" is a very frequently asked question on Usenet.)
755
 
756
Don
757
 
758
======================================================================
759
 
760
**** Can Expect do this? ****
761
 
762
 
763
#20. Can Expect automatically generate a script from watching a session?
764
 
765
From: libes (Don Libes)
766
To: pete@willow24.cray.com
767
Subject: Expect
768
Date: Fri, 12 Oct 90 17:16:47 EDT
769
 
770
>I like "Expect" and am thinking of using it to help automate the
771
>testing of interactive programs.  It would be useful if Expect had a
772
>"watch me" mode, where it "looks over the shoulder" of the user and
773
>records his keystrokes for later use in an Expect script.
774
>
775
>(Red Ryder and other Macintosh telecommunications packages offer this
776
>sort of thing.  You log onto Compuserve once in "watch me" mode, and
777
>RR keeps track of the keystrokes/prompts.  When you're done you have a
778
>script that can be used to log onto Compuserve automatically.)
779
>
780
>Before I look into adding a "watch me" feature, I thought I should
781
>ask: has this been done already?
782
>
783
>I'll say again that I like the tool a lot--nice work!  There are other
784
>people here using it for things like the testing of ksh, which
785
>responds differently to signals when not used interactively.
786
>
787
>-- Pete
788
 
789
The autoexpect script in Expect's example directory does what you
790
want.
791
 
792
Don
793
 
794
======================================================================
795
 
796
#21. Can Expect understand screen-oriented (Curses) programs?
797
 
798
Yes, it can - with a little clever scripting.  Look at the
799
term_expect script for an example.  It uses a Tk text widget to
800
support screen-oriented Expect commands.  This technique is described
801
very thoroughly in Chapter 19 of Exploring Expect.
802
 
803
Adrian Mariano (adrian@cam.cornell.edu) converted the term_expect
804
code (see above) so that it runs without Tk (exercise 4 in Chapter
805
19!)  Both term_expect and virterm can be found in the example
806
directory that comes with Expect.
807
 
808
An alternative approach to screen-handling was demonstrated by Mark
809
Weissman (weissman@gte.com) and Christopher Matheus who modified a
810
version of Expect to include a built-in Curses emulator.  It can be
811
ftp'd from the Tcl archive as expecTerm1.0beta.tar.Z.  (Note that
812
Expecterm does not run with the current version of Expect.)
813
 
814
I like the idea of keeping the curses emulator outside of Expect
815
itself.  It leaves the interface entirely defineable by the user.  And
816
you can do things such as define your own terminal types if you want.
817
For these reasons and several others, I'm not likely to return to
818
Expecterm.
819
 
820
Don
821
 
822
======================================================================
823
 
824
#22. Can Expect be run as a CGI script?
825
 
826
Expect scripts work fine as CGI scripts.  A couple pointers might
827
help to get you going:
828
 
829
Many Expect scripts can be run directly with one change - the
830
following line should be inserted before any other output:
831
 
832
puts "Content-type: text/html\n"
833
 
834
Be sure not to forget that extra newline at the end of the puts.
835
 
836
Next, make sure you invoke external programs using full paths.  For
837
example, instead of "spawn telnet", use "spawn /usr/ucb/telnet" (or
838
whatever).  Remember that the PATH and other environment variables are
839
going to be different than what you are used to.  This is very similar
840
to dealing with cron and you can get other good tips and advice from
841
reading the Background chapter in the book.
842
 
843
 One last tip: If a script runs fine by hand but not from CGI, just
844
log in as "nobody" to the host on which your CGI script runs.  Then
845
try running it by hand.  This generally makes it very obvious what's
846
going on.  (If you can't log in to the server or can't log in as
847
"nobody", use the kibitz trick described in the Background chapter.)
848
 
849
Don
850
 
851
======================================================================
852
 
853
#23. Can Expect be run from cron?
854
 
855
Expect itself works fine from cron - however, you can cause
856
problems if you do things that don't make sense in cron - such as
857
assume that there is a terminal type predefined.  There are a number
858
of other pitfalls to watch out for.  The list and explanations aren't
859
short - which is why there's a whole chapter ("Background") on the
860
subject in the book.
861
 
862
Here's one that someone tried to stump me with recently: They told
863
me that their program started up and then Expect immediately exited.
864
We spent a lot of time tracking this down (Was the spawned program
865
really starting up but then hanging - which would indicate a bug in
866
the program; or was the program NOT starting up - which would indicate
867
a bug in the environment; etc.)  Turned out that Expect wasn't even
868
running their program.  They had assumed cron honored the #! line
869
(which it doesn't) and so the first line in their script (exec date)
870
was being interpreted by the shell and of course, the script did
871
nothing after that - because that's what the shell's exec is supposed
872
to do!)
873
 
874
Don
875
 
876
======================================================================
877
 
878
**** Compilation or porting questions ****
879
 
880
 
881
#24. Why can't I compile Expect with Tcl 7.5?
882
 
883
You can - you just need a newer version of Expect.  Note that the
884
production release of Tcl 7.5 was just released and a compatible
885
Expect is still in beta.  So you shouldn't do this without
886
caution.
887
 
888
Expect 5.19 works fine with Tcl 7.4.  If you stay with Tcl 7.4, I
889
encourage you to upgrade to Expect 5.19 if you haven't already.
890
 
891
Don
892
 
893
======================================================================
894
 
895
#25. Why does Expect need to be setuid root on Cray?
896
 
897
From: libes (Don Libes)
898
To: u70217@f.nersc.gov (Lori Wong)
899
Subject: setuid in Expect
900
Date: Thu, 24 Oct 91 16:15:20 EDT
901
 
902
>     I have been running Expect now under UNICOS 6.1 and CSOS 1.0 (Cray
903
>Computer Corporation's OS).  The two machines that I am running Expect
904
>on have stringent security features, one of which is to limit setuid
905
>privileges to specific individuals.  I was wondering if you would be
906
>kind enough to explain the purpose of the setuid that is needed by Expect
907
>and whether it could be compiled to run without having to have setuid
908
>privilege?  I know it has to do with spawning and communicating with
909
>the various spawned tasks, but don't know enough of the details to be
910
>able to explain why Expect specifically needs setuid and whether or not
911
>it could cause a security problem (could someone use it to enter into
912
>the system and wreak havoc, for example?).  Right now, I've limited
913
>the access of Expect to my group, but need to know what the security
914
>implications are if I open it to all users.  I'd appreciate any light
915
>you can shed on this subject...
916
 
917
Root-access is needed to open a pty under Unicos.  Thus, all programs
918
accessing ptys must be setuid root.  If you do an "ls -l" of programs
919
like "script", "xterm", etc, you'll see this.
920
 
921
I have no idea why this is.  The requirement was probably for security
922
reasons to begin with, but it has the ironic effect of making more
923
programs require setuid and therefore greater possibility of errant
924
setuid programs.
925
 
926
In fact, there is one known Unicos bug relating to the way uids are
927
switched at exec time which requires further special coding.  If you
928
search for "Cray" in the Expect source you will see significant chunks
929
of code to get around the problem.
930
 
931
I don't know if this reassures you any.  All I can tell you is that a
932
number of Cray experts have looked into the situation and are happy
933
with the current implementation of Expect.
934
 
935
Don
936
 
937
======================================================================
938
 
939
#26. Does Expect run on VMS?
940
 
941
From: libes (Don Libes)
942
To: Cameron Laird 
943
Subject: VMS question.
944
 
945
Cameron Laird writes:
946
>Do you know of anyone working with Expect and VMS?
947
>I'd like not to re-invent wheels, but, if I'm to be
948
>the first one, I want others to benefit.
949
 
950
No, I'm not aware of anyone doing it.  Since VMS claims POSIX
951
conformance, it shouldn't be that hard - Expect uses the POSIX calls
952
if it can.  Probably the hardest part will just be modifying the Makefile
953
and the configure script!
954
 
955
However, that there might be a simpler solution.  The neat thing
956
about Expect is that you can control other computers easily.  Run
957
Expect on your UNIX box and have it log in to the VMS box and do its
958
thing.  (You can bypass the login garbage by using an inet daemon.)
959
We've done exactly this to a number of weird pieces of hardware we
960
have around the lab (robots, Lisp machines, embedded controllers, and,
961
of course, a VAX running VMS).  It saves time porting!
962
 
963
Don
964
 
965
======================================================================
966
 
967
#27. Is it possible to use Expect and TclX together?
968
 
969
Is it possible to use Expect and TclX together?
970
From: bfriesen@iphase.com (Bob Friesenhahn)
971
Date: 20 Jul 1994 04:09:43 GMT
972
Organization: Interphase Corporation, Dallas TX - USA
973
 
974
Jeffery A. Echtenkamp (echtenka@michigan.nb.rockwell.com) wrote:
975
: Do Expect and tclX work together? If so, must anything special be done to
976
: get them to work together?
977
 
978
This answer courtesy of Bob Friesenhahn, Interphase (bfriesen@iphase.com):
979
 
980
They work fine together.  However, you should prepend "exp_" to your Expect
981
command names.  This will ensure that there are no conflicts between Expect
982
commands and tclX commands of the same name (like wait).
983
 
984
Just pick up the "make-a-wish" package, follow the instructions, and you will
985
be all set.  I have built a wish based on tcl, tk, Expect, tclX, and dp using
986
this technique with no observed problems.
987
 
988
Bob
989
 
990
[If you need additional information, please read Chapter 22
991
("Expect as Just Another Tcl Extension") of Exploring Expect.  Its
992
sole focus is how to make Expect work with other extensions. - Don]
993
======================================================================
994
 
995
#28. Is it possible to use Expect and  together?
996
 
997
From: libes (Don Libes)
998
To: Frank Winkler 
999
Subject: Q Expect + TkSteal
1000
 
1001
Frank Winkler writes:
1002
>Hi don,
1003
>
1004
>a short question considering installation of Expectk.
1005
>
1006
>Is it possible to build an Expectk-binary, which uses
1007
>the features of BLT, TkSteal and Expect ?
1008
 
1009
I've never done it, but I know it must be possible because the tgdb
1010
package in the Tcl archive uses all of those extensions with Expect.
1011
 
1012
Expect is a "well-behaved extension" in the sense that it requires no
1013
changes to the Tcl core.  So Expect should work with any other Tcl
1014
extensions.  You just need to add the usual Exp_Init call to main() or
1015
the other _Init calls to Expect's main.
1016
 
1017
>If yes, which of them should be build first, second ... ?
1018
 
1019
Order doesn't matter.
1020
 
1021
I've done this kind of thing by hand.  It's pretty simple.  But people
1022
tell me the make-a-wish package in the Tcl archive automates the
1023
creation of multi-extension Tcl applications.
1024
 
1025
[Also see the answer to the previous FAQ answer.]
1026
 
1027
Don
1028
 
1029
======================================================================
1030
 
1031
#29. Why does configure complain about "cross-compiling"?
1032
 
1033
From: libes (Don Libes)
1034
To: morton@hendrix.jci.tju.edu (Dan Morton)
1035
Subject: Re: Sorry to bother you, but...
1036
 
1037
Dan Morton writes:
1038
>Don,
1039
>
1040
>I've posted an inquiry to comp.lang.tcl about my configure problems with
1041
>expect, but I've not yet gotten a reply.  Perhaps you can nudge me in the
1042
>right direction?
1043
>
1044
>I'm running HP-UX 9.0 on a 735, and I've snagged the latest versions of Tcl
1045
>and expect from NIST (7.4 and 5.18 respectively).  My gcc is v2.6.  Tcl
1046
>configured and built out of the box, but I can't get expect to configure
1047
>properly.  No matter what I do, it thinks it wants to cross-compile.  I
1048
>think it's failing that little snippet of eval code.  It gets further if I
1049
>specify --host=HP, but still complains about cross compiling.  Here's the
1050
>result without options:
1051
>
1052
>{hendrix:~/expect-5.18:8} ./configure
1053
>checking for gcc... gcc
1054
>checking whether we are using GNU C... yes
1055
>checking whether gcc accepts -g... no
1056
>checking how to run the C preprocessor... gcc -E
1057
>checking whether cross-compiling... yes
1058
>checking whether cross-compiling... (cached) configure: error: You need to
1059
>specify --target to cross compile,
1060
>        or the native compiler is broken
1061
 
1062
I guess the error message has to be clearer.  The message:
1063
 
1064
        "or the native compiler is broken"
1065
 
1066
means that configure tried to compile a simple program and it failed.
1067
Here's the program it tries to compile:
1068
 
1069
        main() {
1070
                return(0);
1071
        }
1072
 
1073
The configure output that you showed me says that it found gcc.
1074
Perhaps it was misinstalled or is just a placeholder and doesn't
1075
actually do anything?  Try compiling a tiny C program yourself from
1076
the command line.
1077
 
1078
Don
1079
 
1080
======================================================================
1081
 
1082
#30. make/configure seems to be looping endlessly
1083
 
1084
To: Xiaorong Qu 
1085
Subject: Make message for Expect
1086
--text follows this line--
1087
Xiaorong Qu writes:
1088
>Don,
1089
>
1090
>The following is the output of make, you can find
1091
>that the process repeated three times.
1092
 
1093
I bet what's going on is that your system clock is set to some
1094
ridiculous time such as last year.  "Make" is sensitive to your clock.
1095
Please fix your clock.  Then check that all the files are "older"
1096
than the current time.  (If not, "touch" them all.)
1097
 
1098
Don
1099
 
1100
======================================================================
1101
 
1102
#31. Compile fails with: Don't know how to make pty_.c
1103
 
1104
From: libes (Don Libes)
1105
To: wren@io.nosc.mil
1106
Subject: Compile fails with: Don't know how to make pty_.c
1107
 
1108
>   I'm trying to compile Expect on hpux 9.01,
1109
>   downloaded from ftp.cme.nist.gov expect.tar
1110
 
1111
>   after running config
1112
>   the make fails with  "Don't know how to make pty_.c. (compile fails)
1113
>   I see three versions pty_sgttyb.c, pty_termios.c and pty_unicos.c in
1114
>   the load, but the configure picked none of them.
1115
>   I tried forcing to pty_termios.c but that failed with other compile errors.
1116
 
1117
I've seen this happen because gcc was partially installed.  configure
1118
finds the gcc stub and uses gcc for all the tests.  But because the
1119
compiler doesn't work, every test fails so configure doesn't select
1120
any of the choices.
1121
 
1122
So either finish installing gcc or delete the stub.
1123
 
1124
(And if it's not that, then something similar is wrong with whatever
1125
compiler you've got.  Look closely at the output from configure, it
1126
will tell you what compiler it is trying to use.)
1127
 
1128
By the way, Expect compiles fine on my HP (A.09.05 E 9000/735).
1129
 
1130
Don
1131
 
1132
======================================================================
1133
 
1134
#32. Does Expect run on MSDOS, Win95, WinNT, MacOS, etc...
1135
 
1136
From: libes (Don Libes)
1137
To: Gerry_Jones@qmgateib.mitre.org
1138
Subject: Does Expect run on ...
1139
Date: Wed, 11 Oct 95 19:57:42 EDT
1140
 
1141
>I am in a group looking into developing script language-based applications for
1142
>Mac and PC-Windows environments.  Our intent is to write scripts to work with
1143
>interactive applications (e.g. telnet).  After asking around, I started
1144
>looking into Tcl/Tk, which now have 'official' (?) (alpha) Mac and PC-Windows
1145
>ports.  One of the people in our group has been working (in UNIX) with Tcl and
1146
>Tk for quite some time, and said if there isn't an Expect port or similar tool
1147
>for Mac and PC-Windows, then we shouldn't use Tcl/Tk; i.e. they would be too
1148
>limited and/or require too much work to do what we need.  I've been cruising
1149
>the Web for information, reading the Newsgroups, read the FAQs, etc., and have
1150
>the following questions:
1151
>
1152
>1) Is there a current or planned port of Expect to Mac or PC-Windows
1153
>environments?
1154
 
1155
No, Expect isn't currently portable to Windows or Mac.  Let me know
1156
if you're seriously interested in a lot of work.  I'm not saying it's
1157
not possible.  It's definitely possible and the porting work at Sun
1158
has made it easier than before.  But it's still not a weekend hack.
1159
Far from it.
1160
 
1161
I actually requested some time to work on it this year and
1162
management said ("sure Don, go ahead") but I see now that they
1163
approved approximately 65 weeks worth of projects for me for the
1164
second half of the fiscal year.  (Yes, I'm serious, they really did.)
1165
So I wouldn't hold my breath on this.  I'm really hoping someone
1166
skilled with UNIX and NT volunteers some time.  Funding contributions
1167
would also help.
1168
 
1169
If you are a student and would like a fun but demanding job for the
1170
summer, let me know.  I'd be willing to let someone come up to speed
1171
even if you don't already have all the skills.  And we offer
1172
continuing internships if you'd like to come back for a semester or
1173
two.  Pay is competitive.  Note: you must be a US citizen and you must
1174
have good grades just to get through our personnel department.
1175
 
1176
Don
1177
 
1178
======================================================================
1179
 
1180
**** Other... ****
1181
 
1182
 
1183
#33. Is it possible to prevent Expect from printing out its interactions?
1184
 
1185
From: libes (Don Libes)
1186
To: Sunanda Iyengar 
1187
Subject: Disabling display from Expect
1188
 
1189
Sunanda Iyengar writes:
1190
>Is it possible to have Expect interact with a process and not print-out
1191
>the results of interaction? In my application, I need it to go into a
1192
>silent mode, communicate with a process without reporting to the user, and
1193
>then come back to normal mode and  put the process into interactive mode.
1194
 
1195
Use the following command:
1196
 
1197
        log_user 0
1198
 
1199
To restore output:
1200
 
1201
        log_user 1
1202
 
1203
See the Expect man page for more details or page 175 of Exploring
1204
Expect for details and examples.
1205
 
1206
Don
1207
 
1208
======================================================================
1209
 
1210
#34. Why does it send back the same string twice?
1211
 
1212
From: Don Libes
1213
To: yusufg@himalaya.cc.gatech.edu (Yusuf Goolamabbas)
1214
Subject: Duplicate pattern matches in Expectk
1215
--text follows this line--
1216
   Hi, I am trying to do a very simple thing in expectk
1217
 
1218
   spawn cat
1219
   expect_background -re ".+" {
1220
           send $expect_out(0,string)
1221
   }
1222
   exp_send "Hello World\n"
1223
 
1224
   Now the display in the text widget looks like this
1225
   Hello World\r
1226
   Hello World\r
1227
 
1228
   whereas I was expecting only one line
1229
   Hello World\r
1230
 
1231
   Thanks in advance, Yusuf
1232
   --
1233
   Yusuf Goolamabbas                               yusufg@cc.gatech.edu
1234
   Graphics, Visualization, & Usability Center     (O) 404.894.8791
1235
   College of Computing Georgia Tech
1236
   http://www.cc.gatech.edu/grads/g/Yusuf.Goolamabbas/home.html
1237
 
1238
This is correct behavior.  The first "Hello World" is echoed by the
1239
terminal driver.  The second is echoed by cat.  This behavior has
1240
nothing to do with Expectk (or Expect for that matter).  You can see
1241
this same thing if you type to cat interactively.
1242
 
1243
% cat
1244
Hello World
1245
Hello World
1246
 
1247
In the example above, I typed "cat" at the shell prompt and pressed
1248
return.  Then I entered "Hello World" and pressed return.  Looking at
1249
the output I *see* "Hello World" twice even though I only entered it
1250
once.
1251
 
1252
You can account for this behavior in your patterns.  Alternatively,
1253
just turn off the echo.  In your particular case though, it's doing
1254
the right thing, showing you the result of an interactive cat just as
1255
if you had typed it yourself.
1256
 
1257
In practice, this kind of problem doesn't arise - because programs
1258
like cat aren't spawned (except in very special situations).  I assume
1259
that cat was just something you chose to experiment with.
1260
 
1261
Don
1262
 
1263
======================================================================
1264
 
1265
#35. Why can't I send the line "user@hostname\r"?
1266
 
1267
From: libes (Don Libes)
1268
To: bt@nadine.hpl.hp.com
1269
Subject: Re: [Q] Expect, ftp and '@'
1270
 
1271
>   I am attempting to use Expect to perform anonymous ftp gets without
1272
>my having to type all the stuff --- I mean, waaaiiiting for the
1273
>prompt, entering a-n-o-n-y-m-o-u-s with my fat fingers, and the rest.
1274
>
1275
>   But I have a probleme: as I set the password to be my e-mail address:
1276
>   set password "bt@hplb.hpl.hp.com"
1277
 
1278
> the ftp servers seem not to receive neither my login name nor the
1279
>at-sign. Some of them do not care, some others say "ok, but don't do
1280
>that again", and the last ones throw me off.
1281
 
1282
The short answer is to upgrade to Expect 5.20 or later.  (Warning:
1283
5.20 is still in beta.)  If you don't feel like doing this,
1284
here's the explanation for older versions of Expect:
1285
 
1286
spawn initializes the terminal by using your current parameters and
1287
then forces them to be "sane".  Unfortunately, on your system, "sane"
1288
says to interpret the "@" as the line-kill character.
1289
 
1290
The most sensible thing to do is change "sane" in your Makefile to
1291
something that makes sense.  (Since you work at HP, you might also
1292
suggest that they modernize stty!)
1293
 
1294
Here's an example of a replacement line for the Makefile:
1295
 
1296
        STTY = -DDFLT_STTY=\""sane kill ^U"\"
1297
 
1298
Other alternatives are: quote the @, or use the -nottyinit flag, or
1299
set the stty_init variable.
1300
 
1301
Don
1302
 
1303
======================================================================
1304
 
1305
#36. How do I hide the output of the send command?
1306
 
1307
From: tim@mks.com (Timothy D. Prime)
1308
Subject: Re: hide the text of expect's send command?
1309
Date: 29 Mar 1996 15:41:02 GMT
1310
 
1311
In article , Kirby Hughes  wrote:
1312
> I don't want to see (on the screen) the text sent by a "send" command.  Is
1313
> there a way to hide it?  "log_user 0" works for text coming back to me, but
1314
> doesn't (seem to) work for sending...
1315
>
1316
> #!/usr/local/bin/expect --
1317
> log_user 0
1318
> spawn telnet proxy
1319
> expect Command
1320
> send "c [lrange $argv 0 1]\n"
1321
> log_user 1
1322
> interact
1323
 
1324
This answer courtesy of Timothy Prime, Mortice Kern Systems (tim@mks.com):
1325
 
1326
The output you are seeing wasn't printed by the send command.
1327
(I.e., the log_user command is working just fine.)  The output you see
1328
is from the interact command.  The interact command found program
1329
output and thus wrote it to the terminal so that you could see it.
1330
That's what the interact command is supposed to do!
1331
 
1332
Although the expanation might take a little thought, the solution is
1333
easy.  Simply put an expect command in before the command "log_user 1".
1334
Match against the last characters that you wish to suppress.
1335
======================================================================
1336
 
1337
#37. Why does "talk" fail with "Who are you?  You have no entry utmp" or
1338
        "You don't exist.  Go away".
1339
 
1340
From: libes (Don Libes)
1341
To: Will Smith (AC) 
1342
Subject: Expect
1343
 
1344
Will Smith (AC) writes:
1345
>Hi there.  I was wondering if you had any ideas to why i am getting
1346
>this problem running an Expect script which tries to spawn a talk
1347
>process to myself on another machine. Would it have anything to do
1348
>with the fact that the executables are NOT installed in /usr/local/bin
1349
>or because it wasnt installed by ROOT or what. This is what my Expect
1350
>script looks like.
1351
>
1352
>#! /home/ritchie/ops/william/test/expect -f
1353
>
1354
>spawn talk william@curiac.acomp
1355
>set timeout 200
1356
>expect {*established*}
1357
>set send_human {.1 .3 1 .05 2}
1358
>send -h "This is only a test.. I swear \ Please don't bust me with expect \n  >expect "{*\r*}"
1359
>expect "{*\r*}"
1360
>exec sleep 5
1361
>send -h "Ok, well see ya tomorrow you idiot \n"
1362
>exec sleep 3
1363
>
1364
>The error i get is that it returns this when i run the script.
1365
>
1366
>  Who are you? You have no entry in /etc/utmp! Aborting...
1367
 
1368
On most systems, Expect does not automatically make a utmp entry.  (A
1369
utmp entry normally indicates login information which seems kind of
1370
pointless for Expect scripts.)  This allows Expect to run non-setuid.
1371
 
1372
Normally, this lack of utmp entries doesn't mean much.  However, a few
1373
programs actually refuse to run without a utmp entry.  Fortunately,
1374
there are workarounds:
1375
 
1376
Program-dependent solutions:
1377
 
1378
"talk" is the only program I'm aware of that falls into this category.
1379
One solution is to get ytalk.  ytalk doesn't have this problem plus it
1380
fixes many other bugs in talk, such as being able to communicate with
1381
both old and new talk.
1382
 
1383
Program-independent solutions:
1384
 
1385
Use a program specifically intended to create utmp entries.  Such
1386
programs are easy to write or get if you don't have them already.  For
1387
instance, sessreg is one which comes with the xdm distribution.  And
1388
Solaris uses utmp_update.  I like this approach because it isolates
1389
the setuid code in a small single system utility rather than in every
1390
program on the system that needs this ability.
1391
 
1392
Don
1393
 
1394
======================================================================
1395
 
1396
#38. Why does . match a newline?
1397
 
1398
From: libes (Don Libes)
1399
To: xipr@alv.teli.se (Ivan Prochazka)
1400
Subject: Why does . match a newline?
1401
Ivan Prochazka writes:
1402
>
1403
>Hello Don.
1404
>
1405
>In my opinion(and emacs) the regexp-symbol "." stands for all
1406
>characters except newline(\n).
1407
>This is not the case in Expect 5.2.
1408
 
1409
Yes, there are some packages that follow this convention, but I don't
1410
think it is appropriate for Expect.  Unlike emacs, most Expect
1411
patterns don't look for full lines - more often they look for prompts
1412
which *don't* end with newlines.
1413
 
1414
I find that I actually write the [^\n] pattern very rarely.  And
1415
if I write it frequently in a script, then the expect itself probably
1416
ought to be in a subroutine.
1417
 
1418
In fact, the more common line-terminating sequence in Expect is \r\n,
1419
so that might make a more likely argument.  In any case, Expect
1420
defines . the way POSIX does.  So I feel pretty good about the
1421
definition of . being what it is.
1422
 
1423
Don
1424
 
1425
======================================================================
1426
 
1427
#39. Why doesn't Expect kill telnet (or other programs) sometimes?
1428
 
1429
From: libes (Don Libes)
1430
To: Karl.Sierka@Labyrinth.COM
1431
Subject: Re: need help running telnet Expect script from cron on sunos 4.1.3
1432
 
1433
karl.sierka@labyrinth.com writes:
1434
>       The only problem I am still having with the script I wrote is that
1435
>    the telnet does not seem to die on it's own, unless I turn on debugging.
1436
 
1437
Actually, Expect doesn't explicitly kill processes at all.  Generally,
1438
processes kill themselves after reading EOF on input.  So it just seems
1439
like Expect kills all of its children.
1440
 
1441
>    I was forced to save the pid of the spawned telnet, and kill it with an
1442
>    'exec kill $pid' in a proc that is hopefully called before the script
1443
>    exits. This seems to work fine, but it makes me nervous since omnet
1444
>    charges for connect time, and leaving a hung telnet lying around could
1445
>    get expensive. I warned the rest of the staff so that they will also be
1446
>    on the lookout for any possible hung telnets to omnet.
1447
 
1448
The problem is that telnet is not recognizing EOF.  (This is quite
1449
understandable since real users can't actually generate one from the
1450
telnet user interface.)  The solution is to either 1) explicitly drive
1451
telnet to kill itself (i.e., a graceful logout) followed by "expect
1452
eof" or 2) "exec kill" as you are doing.
1453
 
1454
This is described further in Exploring Expect beginning on page 103.
1455
 
1456
Don
1457
 
1458
======================================================================
1459
 
1460
#40. How come I get "ioctl(set): Inappropriate ..., bye recursed" ...
1461
 
1462
From: libes (Don Libes)
1463
To: james@Solbourne.COM (James B. Davis)
1464
Subject: How come I get "ioctl(set): Inappropriate ..., bye recursed" ...
1465
Date: Tue, 10 Dec 91 10:47:21 MST
1466
 
1467
>Every time I ^C out of a Expect script run I get:
1468
>
1469
>ioctl(set): Inappropriate ioctl for device
1470
>bye recursed
1471
>
1472
>james@solbourne.com
1473
 
1474
This answer courtesy of Michael Grant (mgrant@xdr.ncsl.nist.gov):
1475
 
1476
You (or whoever installed gcc) forgot to run the fixincludes shell
1477
script while installing gcc.  Recompiled gcc with itself, then run the
1478
fixincludes script - and the messages will go away.
1479
 
1480
Michael Grant
1481
======================================================================
1482
 
1483
#41. How come there's no interact function in the Expect library?
1484
 
1485
From: libes (Don Libes)
1486
To: Djamal SIMOHAND 
1487
Subject: Re: exp_expectl
1488
Date: Wed, 3 Jan 96 12:17:01 EST
1489
 
1490
Djamal SIMOHAND writes:
1491
>I have already used the Expect program to write a script to connect by
1492
>telnet on my machine.  Now I made a graphic interface in C and I need
1493
>the expect in C in order to have a coherent executable.
1494
>
1495
>I've already written most of the C already, but the connection is
1496
>closed just after my program is finished.  Then I have no opportunity
1497
>to work on my machine.  It seems I need of the equivalent of
1498
>"interact" in C.  Is there such a function in the C library?
1499
>
1500
>Thanks for your help,
1501
>                                                      Djamal
1502
 
1503
No, there is no interact-like function in the C library.  The reason
1504
is three-fold:
1505
 
1506
1) It is simple enough to write your own.  It's just a loop after
1507
all:
1508
 
1509
        while 1 {
1510
                select/poll()
1511
                read()
1512
                write()
1513
        }
1514
 
1515
2) There's no way I could possibly provide all the options you might
1516
need.  In Expect, it's not a problem because the environment is very
1517
controlled, but in C, it's impossible to control what you might want
1518
to do.  For example, you mention that you're embedding your code in a
1519
graphics application.  Graphics packages typically have their own
1520
event manager, so you wouldn't want a monolithic interact function.
1521
 
1522
3) The library is intended for embedding in other applications, where
1523
it rarely makes sense to give the user direct control of a spawned
1524
process.  That kind of thing makes so much more sense to handle with
1525
an Expect script than a C program.  The C library was not intended as
1526
a replacement for Expect.  Expect is really the tool of choice for
1527
interaction problems, not C.
1528
 
1529
In summary, there's very little payoff for the library to supply an
1530
interact function.  A simple one would only satisfy people who should
1531
be using Expect anyway - and it's impossible to create one that would
1532
do everything that everyone wants.  It's easier just to let people
1533
roll their own.
1534
 
1535
Don
1536
 
1537
======================================================================
1538
 
1539
 
1540
Names of companies and products, and links to commercial pages are
1541
provided in order to adequately specify procedures and equipment used.
1542
In no case does such identification imply recommendation or
1543
endorsement by the National Institute of Standards and Technology, nor
1544
does it imply that the products are necessarily the best available for
1545
the purpose.
1546
 
1547
Last edited: Thu Jun  6 07:35:19 EDT 1996 by Don Libes

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.