Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(397)

Side by Side Diff: third_party/pexpect/doc/commonissues.rst

Issue 1398903002: Add third_party/pexpect (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@end-to-end-test
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/pexpect/doc/clean.css ('k') | third_party/pexpect/doc/conf.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 Common problems
2 ===============
3
4 Threads
5 -------
6
7 On Linux (RH 8) you cannot spawn a child from a different thread and pass the
8 handle back to a worker thread. The child is successfully spawned but you can't
9 interact with it. The only way to make it work is to spawn and interact with the
10 child all in the same thread. [Adam Kerrison]
11
12 Timing issue with send() and sendline()
13 ---------------------------------------
14
15 This problem has been addressed and should not affect most users.
16
17 It is sometimes possible to read an echo of the string sent with
18 :meth:`~pexpect.spawn.send` and :meth:`~pexpect.spawn.sendline`. If you call
19 :meth:`~pexpect.spawn.send` and then immediately call :meth:`~pexpect.spawn.read line`,
20 you may get part of your output echoed back. You may read back what you just
21 wrote even if the child application does not explicitly echo it. Timing is
22 critical. This could be a security issue when talking to an application that
23 asks for a password; otherwise, this does not seem like a big deal. But why do
24 TTYs do this?
25
26 People usually report this when they are trying to control SSH or some other
27 login. For example, if your code looks something like this::
28
29 child.expect ('[pP]assword:')
30 child.sendline (my_password)
31
32
33 1. SSH prints "password:" prompt to the user.
34 2. SSH turns off echo on the TTY device.
35 3. SSH waits for user to enter a password.
36
37 When scripting with Pexpect what can happen is that Pexpect will respond to the
38 "password:" prompt before SSH has had time to turn off TTY echo. In other words,
39 Pexpect sends the password between steps 1. and 2., so the password gets echoed
40 back to the TTY. I would call this an SSH bug.
41
42 Pexpect now automatically adds a short delay before sending data to a child
43 process. This more closely mimics what happens in the usual human-to-app
44 interaction. The delay can be tuned with the ``delaybeforesend`` attribute of th e
45 spawn class. In general, this fixes the problem for everyone and so this should
46 not be an issue for most users. For some applications you might with to turn it
47 off::
48
49 child = pexpect.spawn ("ssh user@example.com")
50 child.delaybeforesend = 0
51
52 Truncated output just before child exits
53 ----------------------------------------
54
55 So far I have seen this only on older versions of Apple's MacOS X. If the child
56 application quits it may not flush its output buffer. This means that your
57 Pexpect application will receive an EOF even though it should have received a
58 little more data before the child died. This is not generally a problem when
59 talking to interactive child applications. One example where it is a problem is
60 when trying to read output from a program like *ls*. You may receive most of the
61 directory listing, but the last few lines will get lost before you receive an EO F.
62 The reason for this is that *ls* runs; completes its task; and then exits. The
63 buffer is not flushed before exit so the last few lines are lost. The following
64 example demonstrates the problem::
65
66 child = pexpect.spawn('ls -l')
67 child.expect(pexpect.EOF)
68 print child.before
69
70 Controlling SSH on Solaris
71 --------------------------
72
73 Pexpect does not yet work perfectly on Solaris. One common problem is that SSH
74 sometimes will not allow TTY password authentication. For example, you may
75 expect SSH to ask you for a password using code like this::
76
77 child = pexpect.spawn('ssh user@example.com')
78 child.expect('password')
79 child.sendline('mypassword')
80
81 You may see the following error come back from a spawned child SSH::
82
83 Permission denied (publickey,keyboard-interactive).
84
85 This means that SSH thinks it can't access the TTY to ask you for your password.
86 The only solution I have found is to use public key authentication with SSH.
87 This bypasses the need for a password. I'm not happy with this solution. The
88 problem is due to poor support for Solaris Pseudo TTYs in the Python Standard
89 Library.
90
91 child does not receive full input, emits BEL
92 --------------------------------------------
93
94 You may notice when running for example cat(1) or base64(1), when sending a
95 very long input line, that it is not fully received, and the BEL ('\a') may
96 be found in output.
97
98 By default the child terminal matches the parent, which is often in "canonical
99 mode processing". You may wish to disable this mode. The exact limit of a line
100 varies by operating system, and details of disabling canonical mode may be
101 found in the docstring of :meth:`~pexpect.spawn.send`.
OLDNEW
« no previous file with comments | « third_party/pexpect/doc/clean.css ('k') | third_party/pexpect/doc/conf.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698