Home | History | Annotate | Download | only in pexpect-2.4

Lines Matching refs:PROMPT

2 This adds methods for login, logout, and expecting the shell prompt.
22 prompt. It does various tricky things to handle many situations in the SSH
25 authentication setup then pxssh won't wait for the password prompt.
27 pxssh uses the shell prompt to synchronize output from the remote host. In
28 order to make this more robust it sets the shell prompt to something more
43 s.prompt() # match the prompt
44 print s.before # print everything before the prompt.
46 s.prompt()
49 s.prompt()
78 #SUBTLE HACK ALERT! Note that the command to set the prompt uses a
80 #is because when you set the prompt the command will echo back, but we
85 #prompt command different than the regex.
87 # used to match the command-line prompt
89 self.PROMPT = self.UNIQUE_PROMPT
91 # used to set shell command-line prompt to UNIQUE_PROMPT.
93 self.PROMPT_SET_CSH = "set prompt='[PEXPECT]\$ '"
125 """This attempts to find the prompt. Basically, press enter and record
127 responses are similar then assume we are at the original prompt. This
136 self.read_nonblocking(size=10000,timeout=1) # GAS: Clear out the cache before getting the prompt
164 'original_prompt' to try to find the prompt right after login. When it
165 finds the prompt it immediately tries to reset the prompt to something
168 prompt as exactly as possible to prevent false matches by server
171 called "~/.hushlogin" on the remote server. If a prompt cannot be found
173 a timeout when looking for the prompt we assume that the original
174 prompt was so weird that we could not match it, so we use a few tricks
175 to guess when we have reached the prompt. Then we hope for the best and
176 blindly try to reset the prompt to something more unique. If that fails
180 original prompt. In this case, set 'auto_prompt_reset' to False to
181 inhibit setting the prompt to the UNIQUE_PROMPT. Remember that pxssh
182 uses a unique prompt in the prompt() method. If the original prompt is
183 not reset then this will disable the prompt() method unless you
184 manually set the PROMPT attribute. """
193 # This does not distinguish between a remote server 'password' prompt
194 # and a local ssh 'passphrase' prompt (for unlocking a private key).
216 raise ExceptionPxssh ('Weird error. Got "are you sure" prompt twice.')
218 ### TODO: May NOT be OK if expect() got tricked and matched a false prompt.
220 elif i==2: # password prompt again
223 # If we get the password prompt again then this means
232 raise ExceptionPxssh ('Weird error. Got "terminal type" prompt twice.')
234 #This is tricky... I presume that we are at the command-line prompt.
235 #It may be that the shell prompt was so weird that we couldn't match
239 #later when I try to set the shell prompt.
249 raise ExceptionPxssh ('could not synchronize with original prompt')
251 # set shell prompt to something unique.
255 raise ExceptionPxssh ('could not set shell prompt\n'+self.before)
270 def prompt (self, timeout=20):
272 """This matches the shell prompt. This is little more than a short-cut
273 to the expect() method. This returns True if the shell prompt was
276 manually set the PROMPT attribute to a regex pattern for matching the
277 prompt. """
279 i = self.expect([self.PROMPT, TIMEOUT], timeout=timeout)
286 """This sets the remote prompt to something more unique than # or $.
287 This makes it easier for the prompt() method to match the shell prompt
290 shell prompt. For example, if you 'su' to a different user then you
291 will need to manually reset the prompt. This sends shell commands to
292 the remote host to set the prompt, so this assumes the remote host is
295 Alternatively, you may use your own prompt pattern. Just set the PROMPT
297 should call login() with auto_prompt_reset=False; then set the PROMPT
298 attribute. After that the prompt() method will try to match your prompt
303 i = self.expect ([TIMEOUT, self.PROMPT], timeout=10)
306 i = self.expect ([TIMEOUT, self.PROMPT], timeout=10)