blob: c45928aa637899d4dddc4d617d86c800a3e7adaa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
Hello Noah,
first of all I would like to thank you for pexpect -- it is great and I
use it all the time.
A while back I also wrote something in the same functional space: kdesu.
This also contained a small helper in C++ for interfacing with a
command-line program through a PTY.
When I read the description of the "echo bug" on your page, and saw how
you wanted to solve this (by issueing a delay), I remembered that there
is another way to solve this and this is how I implemented it in kdesu.
You could add a method to pexpect to i) report on the echo status of the
PTY, and 2) wait for echo to become off. The latter may require a
polling loop as I think there is no wait to wait for it (but I am not sure).
The SSH problem you describe could then be solved like this:
child.expect ('[pP]assword:')
child.wait_echo_off()
child.sendline (my_password)
I think this is guaranteed to be race-free and in general feels a bit
cleaner that issueing a delay.
Hope this was useful. In any case keep up the great work with pexpect!
Regards,
Geert Jansen
|