Home | History | Annotate | Download | only in pexpect

Lines Matching refs:PROMPT

2 This adds methods for login, logout, and expecting the shell prompt.
39 prompt. It does various tricky things to handle many situations in the SSH
42 authentication setup then pxssh won't wait for the password prompt.
44 pxssh uses the shell prompt to synchronize output from the remote host. In
45 order to make this more robust it sets the shell prompt to something more
60 s.prompt() # match the prompt
61 print s.before # print everything before the prompt.
63 s.prompt()
66 s.prompt()
96 #SUBTLE HACK ALERT! Note that the command that SETS the prompt uses a
98 #is because when you set the prompt the command will echo back, but we
103 #prompt command different than the regex.
105 # used to match the command-line prompt
107 self.PROMPT = self.UNIQUE_PROMPT
109 # used to set shell command-line prompt to UNIQUE_PROMPT.
111 self.PROMPT_SET_CSH = "set prompt='[PEXPECT]\$ '"
147 """This attempts to find the prompt. Basically, press enter and record
149 responses are similar then assume we are at the original prompt. This
160 # Clear the buffer before getting the prompt.
189 'original_prompt' to try to find the prompt right after login. When it
190 finds the prompt it immediately tries to reset the prompt to something
193 prompt as exactly as possible to prevent false matches by server
196 called "~/.hushlogin" on the remote server. If a prompt cannot be found
198 a timeout when looking for the prompt we assume that the original
199 prompt was so weird that we could not match it, so we use a few tricks
200 to guess when we have reached the prompt. Then we hope for the best and
201 blindly try to reset the prompt to something more unique. If that fails
205 original prompt. In this case, set 'auto_prompt_reset' to False to
206 inhibit setting the prompt to the UNIQUE_PROMPT. Remember that pxssh
207 uses a unique prompt in the prompt() method. If the original prompt is
208 not reset then this will disable the prompt() method unless you
209 manually set the PROMPT attribute. """
224 # This does not distinguish between a remote server 'password' prompt
225 # and a local ssh 'passphrase' prompt (for unlocking a private key).
247 raise ExceptionPxssh ('Weird error. Got "are you sure" prompt twice.')
249 ### TODO: May NOT be OK if expect() got tricked and matched a false prompt.
251 elif i==2: # password prompt again
254 # If we get the password prompt again then this means
263 raise ExceptionPxssh ('Weird error. Got "terminal type" prompt twice.')
265 #This is tricky... I presume that we are at the command-line prompt.
266 #It may be that the shell prompt was so weird that we couldn't match
270 #later when I try to set the shell prompt.
280 raise ExceptionPxssh ('could not synchronize with original prompt')
282 # set shell prompt to something unique.
286 raise ExceptionPxssh ('could not set shell prompt\n'+self.before)
301 def prompt (self, timeout=-1):
303 """This matches the shell prompt. This is little more than a short-cut
304 to the expect() method. This returns True if the shell prompt was
307 prompt() you must set the PROMPT attribute to a regex that prompt()
308 will use for matching the prompt. Calling prompt() will erase the
309 contents of the 'before' attribute even if no prompt is ever matched.
315 i = self.expect([self.PROMPT, TIMEOUT], timeout=timeout)
322 """This sets the remote prompt to something more unique than # or $.
323 This makes it easier for the prompt() method to match the shell prompt
326 shell prompt. For example, if you 'su' to a different user then you
327 will need to manually reset the prompt. This sends shell commands to
328 the remote host to set the prompt, so this assumes the remote host is
331 Alternatively, you may use your own prompt pattern. Just set the PROMPT
333 should call login() with auto_prompt_reset=False; then set the PROMPT
334 attribute. After that the prompt() method will try to match your prompt
339 i = self.expect ([TIMEOUT, self.PROMPT], timeout=10)
342 i = self.expect ([TIMEOUT, self.PROMPT], timeout=10)