Lines Matching full:prompt
3 This adds methods for login, logout, and expecting the shell prompt.
30 prompt. It does various tricky things to handle many situations in the SSH
33 authentication setup then pxssh won't wait for the password prompt.
35 pxssh uses the shell prompt to synchronize output from the remote host. In
36 order to make this more robust it sets the shell prompt to something more
51 s.prompt() # match the prompt
52 print s.before # print everything before the prompt.
54 s.prompt()
57 s.prompt()
86 #SUBTLE HACK ALERT! Note that the command to set the prompt uses a
88 #is because when you set the prompt the command will echo back, but we
93 #prompt command different than the regex.
95 # used to match the command-line prompt
97 self.PROMPT = self.UNIQUE_PROMPT
99 # used to set shell command-line prompt to UNIQUE_PROMPT.
101 self.PROMPT_SET_CSH = "set prompt='[PEXPECT]\$ '"
133 """This attempts to find the prompt. Basically, press enter and record
135 responses are similar then assume we are at the original prompt. """
144 … self.read_nonblocking(size=10000,timeout=1) # GAS: Clear out the cache before getting the prompt
170 'original_prompt' to try to find the prompt right after login. When it
171 finds the prompt it immediately tries to reset the prompt to something
174 prompt as exactly as possible to prevent false matches by server
177 called "~/.hushlogin" on the remote server. If a prompt cannot be found
179 a timeout when looking for the prompt we assume that the original
180 prompt was so weird that we could not match it, so we use a few tricks
181 to guess when we have reached the prompt. Then we hope for the best and
182 blindly try to reset the prompt to something more unique. If that fails
186 original prompt. In this case, set 'auto_prompt_reset' to False to
187 inhibit setting the prompt to the UNIQUE_PROMPT. Remember that pxssh
188 uses a unique prompt in the prompt() method. If the original prompt is
189 not reset then this will disable the prompt() method unless you
190 manually set the PROMPT attribute. """
199 # This does not distinguish between a remote server 'password' prompt
200 # and a local ssh 'passphrase' prompt (for unlocking a private key).
222 raise ExceptionPxssh ('Weird error. Got "are you sure" prompt twice.')
224 ### TODO: May NOT be OK if expect() got tricked and matched a false prompt.
226 elif i==2: # password prompt again
229 # If we get the password prompt again then this means
238 raise ExceptionPxssh ('Weird error. Got "terminal type" prompt twice.')
240 #This is tricky... I presume that we are at the command-line prompt.
241 #It may be that the shell prompt was so weird that we couldn't match
245 #later when I try to set the shell prompt.
255 raise ExceptionPxssh ('could not synchronize with original prompt')
257 # set shell prompt to something unique.
261 raise ExceptionPxssh ('could not set shell prompt\n'+self.before)
276 def prompt (self, timeout=20): member in pxssh
278 """This matches the shell prompt. This is little more than a short-cut
279 to the expect() method. This returns True if the shell prompt was
282 manually set the PROMPT attribute to a regex pattern for matching the
283 prompt. """
285 i = self.expect([self.PROMPT, TIMEOUT], timeout=timeout)
292 """This sets the remote prompt to something more unique than # or $.
293 This makes it easier for the prompt() method to match the shell prompt
296 shell prompt. For example, if you 'su' to a different user then you
297 will need to manually reset the prompt. This sends shell commands to
298 the remote host to set the prompt, so this assumes the remote host is
301 Alternatively, you may use your own prompt pattern. Just set the PROMPT
303 should call login() with auto_prompt_reset=False; then set the PROMPT
304 attribute. After that the prompt() method will try to match your prompt
309 i = self.expect ([TIMEOUT, self.PROMPT], timeout=10)
312 i = self.expect ([TIMEOUT, self.PROMPT], timeout=10)