OSDN Git Service

Convert release and draft pages to UTF-8.
[linuxjm/jm.git] / manual / expect / draft / man1 / autoexpect.1
1 .\" Japanese Version Copyright (c) 2000 Asakawa Satoshi
2 .\"         all rights reserved.
3 .\" Translated Wed Dec 20 16:25:58 JST 2000
4 .\"         by Asakawa Satoshi <rod@i.am>
5 .\"
6 .TH AUTOEXPECT 1 "30 June 1995"
7 .\"O .SH NAME
8 .SH 名前
9 .\"O autoexpect \- generate an Expect script from watching a session
10 autoexpect \- セッションを監視することによりExpectスクリプトを生成する
11
12 .\"O .SH SYNOPSIS
13 .SH 書式
14 .B autoexpect
15 [
16 .I args
17 ]
18 [
19 .I program args...
20 ]
21 .br
22 .\"O .SH INTRODUCTION
23 .SH イントロダクション
24
25 .\"O autoexpect watches you interacting with another program and creates an
26 .\"O Expect script that reproduces your interactions.  For straightline
27 .\"O scripts, autoexpect saves substantial time over writing scripts by
28 .\"O hand.  Even if you are an Expect expert, you will find it convenient
29 .\"O to use autoexpect to automate the more mindless parts of interactions.
30 .\"O It is much easier to cut/paste hunks of autoexpect scripts together
31 .\"O than to write them from scratch.  And if you are a beginner, you may
32 .\"O be able to get away with learning nothing more about Expect than how
33 .\"O to call autoexpect.
34 autoexpectは、あなたとプログラムとの対話を監視し、
35 その対話を再現するExpectスクリプトを生成する。
36 直線的なスクリプトなので、
37 スクリプトを手作業で書くのに比べ相当な時間を節約できる。
38 たとえあなたがExpectのエキスパートだとしても、対話のより機械的な部分を
39 自動化するためにautoexpectを使うと便利であることが分かるだろう。
40 autoexpectの生成したスクリプトの一部をカットアンドペーストした方が
41 ゼロから書き始めるよりとても簡単である。
42 そしてもしあなたが初心者だとしたら、Expectについて何も知らなくても
43 autoexpectの起動方法を習うだけで用が足りるかもしれない。
44
45 .\"O The simplest way to use autoexpect is to call it from the command line
46 .\"O with no arguments.  For example:
47 autoexpectを使う最も簡単な方法は、
48 コマンドラインから引数なしで呼び出すことである。
49 デフォルトでシェルを起動する。
50 .br
51 例:
52 .br
53         % autoexpect
54
55 .\"O By default, autoexpect spawns a shell for you.  Given a program name
56 .\"O and arguments, autoexpect spawns that program.  For example:
57 プログラム名と引数が与えられるとautoexpectはそのプログラムを起動する。
58 .br
59 例:
60 .br
61         % autoexpect ftp ftp.cme.nist.gov
62
63 .\"O Once your spawned program is running, interact normally.  When you
64 .\"O have exited the shell (or program that you specified), autoexpect will
65 .\"O create a new script for you.  By default, autoexpect writes the new
66 .\"O script to "script.exp".  You can override this with the \-f flag
67 .\"O followed by a new script name.
68 一旦プログラムが起動されれば、対話は通常と変わらない。
69 あなたが起動したシェル(または、指定したプログラム)を終了すると
70 autoexpectは新しいスクリプトを生成する。
71 デフォルトでは"script.exp"ファイルに書き込まれる。 
72 \-fフラグを使うとファイル名を指定することができる。
73
74 .\"O The following example runs "ftp ftp.cme.nist.gov" and stores the
75 .\"O resulting Expect script in the file "nist".
76 次は"ftp ftp.cme.nist.gov"を実行し、結果のExpectスクリプトを
77 "nist"ファイルへ格納する例である。
78 .nf
79
80         % autoexpect \-f nist ftp ftp.cme.nist.gov
81
82 .fi
83 .\"O It is important to understand that
84 .\"O autoexpect does not guarantee a working script because it necessarily
85 .\"O has to guess about certain things \- and occasionally it guesses wrong.
86 .\"O However, it is usually very easy to identify and fix these problems.
87 .\"O The typical problems are:
88 autoexpectが生成するスクリプトは動作が保証されている訳ではないという点を
89 理解しておくことが重要である。
90 なぜならば、確かな事柄や時々間違うことを推測しなければならないのだから。
91 しかしながら、通常はこれらの問題を特定し解決することはとても簡単である。
92 .br
93 典型的な問題点は:
94 .RS
95 .TP 4
96 \(bu
97 .\"O Timing.  A surprisingly large number of programs (rn, ksh, zsh,
98 .\"O telnet, etc.) and devices (e.g., modems) ignore keystrokes that arrive
99 .\"O "too quickly" after prompts.  If you find your new script hanging up
100 .\"O at one spot, try adding a short sleep just before the previous send.
101 タイミングの問題。
102 驚くほど多くのプログラム(rn, ksh, zsh, telnet, 等)やデバイス(例えばモデム)
103 は、プロンプトの後の早すぎるキー入力を無視する。
104 もし特定の場所でスクリプトが切れてしまう場合は、先の送信の直前に
105 短いスリープの追加を試みよ。
106
107 .\"O You can force this behavior throughout by overriding the variable
108 .\"O "force_conservative" near the beginning of the generated script.  This
109 .\"O "conservative" mode makes autoexpect automatically pause briefly (one
110 .\"O tenth of a second) before sending each character.  This pacifies every
111 .\"O program I know of.
112 生成されたスクリプトの先頭近くにある"force_conservative"変数を有効にする
113 ことにより、この働きを全体にわたって強制的に行うことができる。
114 この"conservative"モードでは、各々の文字送信の前に自動的に
115 短いポーズ(0.1秒)を入れる。
116 全てのプログラムに対してこの方法は有効である。
117
118 .\"O This conservative mode is useful if you just want to quickly reassure
119 .\"O yourself that the problem is a timing one (or if you really don't care
120 .\"O about how fast the script runs).  This same mode can be forced before
121 .\"O script generation by using the \-c flag.
122 このconservativeモードは、スクリプトの実行がどれほど早いのかは気にせず、
123 ただタイミングの問題か否かを手っ取り早く確かめたいのなら便利である。
124 \-cフラグを付けて実行すると同等のモードを強制することができる。
125
126 .\"O Fortunately, these timing spots are rare.  For example, telnet ignores
127 .\"O characters only after entering its escape sequence.  Modems only
128 .\"O ignore characters immediately after connecting to them for the first
129 .\"O time.  A few programs exhibit this behavior all the time but typically
130 .\"O have a switch to disable it.  For example, rn's \-T flag disables this
131 .\"O behavior.
132 幸運にも、このようなタイミングの場所は稀である。
133 例えば、telnetはエスケープシーケンスを入力した後のみ文字列を無視する。
134 モデムは初回接続直後に文字列を無視するだけである。
135 また少数だがこの働きを無効にするスイッチを持つプログラムもある。
136 例えば、rnの\-Tフラグはこの働きを無効にする。
137
138 .\"O The following example starts autoexpect in conservative
139 .\"O mode.
140 次は、conservativeモードで実行する例である。
141 .nf
142
143         autoexpect \-c
144
145 .fi
146 .\"O The \-C flag defines a key to toggle conservative mode.  
147 .\"O The following example starts autoexpect (in non-conservative
148 .\"O mode) with ^L as the toggle.  (Note that the ^L is
149 .\"O entered literally - i.e., enter a real control-L).
150 \-Cフラグはconservativeモードを切り換えるためのキーを定義する。
151 次は、^Lを切り換えキーと定義し(non-conservativeモードで)実行する例である。
152 (注: ^Lはコントロール+Lを示す)
153 .nf
154
155         autoexpect \-C ^L
156
157 .fi
158 .\"O The following example starts autoexpect in conservative
159 .\"O mode with ^L as the toggle.
160 次は、^Lを切り換えキーと定義しconservativeモードで実行する例である。
161 .nf
162
163         autoexpect \-c \-C ^L
164
165 .fi
166 .TP
167 \(bu
168 .\"O Echoing.  Many program echo characters.  For example, if you type
169 .\"O "more" to a shell, what autoexpect actually sees is:
170 エコーの問題。
171 多くのプログラムが文字をエコーする。例えば、シェルに対して
172 "more"とタイプすると、autoexpectには以下のように見える:
173 .nf
174
175         you typed 'm',
176         computer typed 'm',
177         you typed 'o',
178         computer typed 'o',
179         you typed 'r',
180         computer typed 'r',
181         ...
182 .fi
183
184 .\"O Without specific knowledge of the program, it is impossible to know if
185 .\"O you are waiting to see each character echoed before typing the next.
186 .\"O If autoexpect sees characters being echoed, it assumes that it can
187 .\"O send them all as a group rather than interleaving them the way they
188 .\"O originally appeared.  This makes the script more pleasant to read.
189 .\"O However, it could conceivably be incorrect if you really had to wait
190 .\"O to see each character echoed.
191 そのプログラムに対する特有の知識が無いと、
192 エコーされた文字を待ってから、次の文字をタイプしているのかどうかを
193 知ることは困難である。
194 autoexpectは、文字列がエコーされていると見なすと、元々の対話手順のように
195 細切れに対話するのではなく、グループとして全てを一度に送信できると判断する。
196 このためスクリプトが読み易くなる。
197 しかし、本当にエコーを待ってから入力しなければならない場合には、
198 間違った動作となることが考えられる。
199
200 .TP
201 \(bu
202 .\"O Change.  Autoexpect records every character from the interaction in
203 .\"O the script.  This is desirable because it gives you the ability to
204 .\"O make judgements about what is important and what can be replaced with
205 .\"O a pattern match.
206 変化の問題。
207 autoexpectは対話で生じたすべての文字をスクリプト内に記録する。
208 この事は、どの文字が重要でどの文字は置き換えられるかを判断できるため、
209 好ましいことである。
210
211 .\"O On the other hand, if you use commands whose output differs from run
212 .\"O to run, the generated scripts are not going to be correct.  For
213 .\"O example, the "date" command always produces different output.  So
214 .\"O using the date command while running autoexpect is a sure way to
215 .\"O produce a script that will require editing in order for it to work.
216 しかし一方では、実行する度に異なる出力を生じるコマンドを使う場合、
217 生成されたスクリプトは正しく動作しないかもしれない。
218 例えば、dateコマンドは常に異なる出力を生成する。
219 そのため、autoexpect実行中にdateコマンドを使うと、生成したスクリプトを
220 働かせるためには間違い無く修正が必要になるだろう。
221
222 .\"O The \-p flag puts autoexpect into "prompt mode".  In this mode,
223 .\"O autoexpect will only look for the the last line of program output \-
224 .\"O which is usually the prompt.  This handles the date problem (see
225 .\"O above) and most others.
226 \-pフラグは、autoexpectをpromptモードにする。
227 このモードでは、autoexpectはプログラムの出力する最終行(普通はプロンプト)
228 だけを記録する。
229 このモードは、上述のdateコマンドの問題や他のほとんどの変化の問題を扱う
230 ことができる。
231
232 .\"O The following example starts autoexpect in prompt mode.
233 次は、promptモードで実行する例である。
234 .nf
235
236         autoexpect \-p
237
238 .fi
239 .\"O The \-P flag defines a key to toggle prompt mode.  The following
240 .\"O example starts autoexpect (in non-prompt mode) with ^P as the toggle.
241 .\"O Note that the ^P is entered literally - i.e., enter a real control-P.
242 \-Pフラグはpromptモードを切り換えるためのキーを定義する。
243 次は、^Pを切り換えキーと定義し(non-promptモードで)実行する例である。
244 (注: ^Pはコントロール+Pを示す)
245 .nf
246
247         autoexpect \-P ^P
248
249 .fi
250 .\"O The following example starts autoexpect in prompt mode with ^P as the toggle.
251 次は、^Pを切り換えキーと定義しpromptモードで実行する例である。
252 .nf
253
254         autoexpect \-p \-P ^P
255
256 .fi
257 .\"O .SH OTHER FLAGS
258 .SH 他のフラグ
259 .\"O The
260 .\"O .B \-quiet
261 .\"O flag disables informational messages produced by autoexpect.
262 .B \-quiet
263 フラグは、autoexpectのメッセージ出力を非表示にする。
264
265 .\"O The
266 .\"O .B \-Q
267 .\"O flag names a quote character which can be used to enter characters
268 .\"O that autoexpect would otherwise consume because they are used as toggles.
269 .B \-Q
270 フラグは、引用文字を定義する。
271 引用文字は、切り替えキーとして使われるためautoexpectが別の意味に取って
272 しまう文字を入力するために使うことができる。
273
274 .\"O The following example shows a number of flags with quote used to
275 .\"O provide a way of entering the toggles literally.
276 次は、引用文字と一緒に複数のフラグを定義する例である。
277 引用文字は、切り替えキーを文字通り入力する方法として提供される。
278 .nf
279
280         autoexpect \-P ^P \-C ^L \-Q ^Q
281
282 .fi
283 .\"O .SH STYLE
284 .SH 様式(STYLE)
285
286 .\"O I don't know if there is a "style" for Expect programs but autoexpect
287 .\"O should definitely not be held up as any model of style.  For example,
288 .\"O autoexpect uses features of Expect that are intended specifically for
289 .\"O computer-generated scripting.  So don't try to faithfully write
290 .\"O scripts that appear as if they were generated by autoexpect.  This is
291 .\"O not useful.
292 Expectプログラムのための様式があるか否か分からないが、
293 明らかにautoexpectはどのような様式のモデルにも縛られるべきではない。
294 例えば、コンピュータ生成スクリプト用に意図された Expectプログラムの特徴を
295 autoexpectは利用している。
296 だから、autoexpectによって生成されたかのようなスクリプトを
297 忠実に記述してみてはならない。
298
299 .\"O On the other hand, autoexpect scripts do show some worthwhile things.
300 .\"O For example, you can see how any string must be quoted in order to use
301 .\"O it in a Tcl script simply by running the strings through autoexpect.
302 しかし一方では、autoexpectのスクリプトは価値のある事を示している。
303 例えば、autoexpectを通して実行することにより、
304 Tclスクリプトの中で使用する目的では、どのように文字列は引用されなければ
305 ならないかを簡単に知ることができる。
306
307 .\"O .SH SEE ALSO
308 .SH 関連項目
309 .I
310 "Exploring Expect: A Tcl-Based Toolkit for Automating Interactive Programs"
311 \fRby Don Libes,
312 O'Reilly and Associates, January 1995.
313 .\"O .SH AUTHOR
314 .SH 著者
315 Don Libes, National Institute of Standards and Technology
316
317 .\"O .B expect
318 .\"O and
319 .\"0 .B autoexpect
320 .\"O are in the public domain.
321 .\"O NIST and I would
322 .\"O appreciate credit if these programs or parts of them are used.
323 .B expect
324
325 .B autoexpect
326 は、パブリックドメインである。
327 これらのプログラムあるいは一部が使われたなら、
328 NISTと著者への謝辞を述べてもらいたい。
329
330
331