Home | History | Annotate | Download | only in common_lib

Lines Matching full: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. """
136 self.read_nonblocking(size=10000,timeout=1) # GAS: Clear out the cache before getting the prompt
162 'original_prompt' to try to find the prompt right after login. When it
163 finds the prompt it immediately tries to reset the prompt to something
166 prompt as exactly as possible to prevent false matches by server
169 called "~/.hushlogin" on the remote server. If a prompt cannot be found
171 a timeout when looking for the prompt we assume that the original
172 prompt was so weird that we could not match it, so we use a few tricks
173 to guess when we have reached the prompt. Then we hope for the best and
174 blindly try to reset the prompt to something more unique. If that fails
178 original prompt. In this case, set 'auto_prompt_reset' to False to
179 inhibit setting the prompt to the UNIQUE_PROMPT. Remember that pxssh
180 uses a unique prompt in the prompt() method. If the original prompt is
181 not reset then this will disable the prompt() method unless you
182 manually set the PROMPT attribute. """
191 # This does not distinguish between a remote server 'password' prompt
192 # and a local ssh 'passphrase' prompt (for unlocking a private key).
214 raise ExceptionPxssh ('Weird error. Got "are you sure" prompt twice.')
216 ### TODO: May NOT be OK if expect() got tricked and matched a false prompt.
218 elif i==2: # password prompt again
221 # If we get the password prompt again then this means
230 raise ExceptionPxssh ('Weird error. Got "terminal type" prompt twice.')
232 #This is tricky... I presume that we are at the command-line prompt.
233 #It may be that the shell prompt was so weird that we couldn't match
237 #later when I try to set the shell prompt.
247 raise ExceptionPxssh ('could not synchronize with original prompt')
249 # set shell prompt to something unique.
253 raise ExceptionPxssh ('could not set shell prompt\n'+self.before)
268 def prompt (self, timeout=20):
270 """This matches the shell prompt. This is little more than a short-cut
271 to the expect() method. This returns True if the shell prompt was
274 manually set the PROMPT attribute to a regex pattern for matching the
275 prompt. """
277 i = self.expect([self.PROMPT, TIMEOUT], timeout=timeout)
284 """This sets the remote prompt to something more unique than # or $.
285 This makes it easier for the prompt() method to match the shell prompt
288 shell prompt. For example, if you 'su' to a different user then you
289 will need to manually reset the prompt. This sends shell commands to
290 the remote host to set the prompt, so this assumes the remote host is
293 Alternatively, you may use your own prompt pattern. Just set the PROMPT
295 should call login() with auto_prompt_reset=False; then set the PROMPT
296 attribute. After that the prompt() method will try to match your prompt
301 i = self.expect ([TIMEOUT, self.PROMPT], timeout=10)
304 i = self.expect ([TIMEOUT, self.PROMPT], timeout=10)