Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>pexpect</strong> has no <code>sendcontrol()</code> method. In your example you appear to be trying to send an empty line. To do that, use:</p> <pre><code> id.sendline('') </code></pre> <p>If you need to send real control characters then you can <code>send()</code> a string that contains the appropriate character value. For instance, to send a control-C you would:</p> <pre><code> id.send('\003') </code></pre> <p>or:</p> <pre><code> id.send(chr(3)) </code></pre> <p><em>Responses to comment #2:</em></p> <p>Sorry, I typo'ed the module name -- now fixed. More importantly, I was looking at old documentation on noah.org instead of the <a href="http://pexpect.sourceforge.net/pexpect.html">latest documentation at SourceForge</a>. The newer documentation does show a <code>sendcontrol()</code> method. It takes an argument that is either a letter (for instance, <code>sendcontrol('c')</code> sends a control-C) or one of a variety of punctuation characters representing the control characters that don't correspond to letters. But really <code>sendcontrol()</code> is just a convenient wrapper around the <code>send()</code> method, which is what <code>sendcontrol()</code> calls after after it has calculated the actual value that you want to send. You can read the source for yourself at <a href="http://pexpect.svn.sourceforge.net/viewvc/pexpect/trunk/pexpect/pexpect.py?revision=521&amp;view=markup">line 973 of this file</a>.</p> <p>I don't understand why <code>id.sendline('')</code> does not work, especially given that it apparently works for sending the user name to the spawned <strong>ftp</strong> program. If you want to try using <code>sendcontrol()</code> instead then that would be either:</p> <pre><code> id.sendcontrol('j') </code></pre> <p>to send a Linefeed character (which is control-j, or decimal 10) or:</p> <pre><code> id.sendcontrol('m') </code></pre> <p>to send a Carriage Return (which is control-m, or decimal 13).</p> <p>If those don't work then please explain exactly what does happen, and how that differs from what you wanted or expected to happen.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload