>>> from pexpect import pxssh
>>> s=pxssh.pxssh()
>>> s.login('IP','USER','PASSWORD',auto_prompt_reset=True)
True
>>> s.sendline('echo Test');
10
>>> s.prompt()
True
>>> s.after
'[PEXPECT]# '
>>> s.PROMPT='BTEQ -- Enter your SQL request or BTEQ command:'
>>> s.sendline('bteq .logon dbc,dbc')
20
>>> s.prompt()
True
>>> s.after
'BTEQ -- Enter your SQL request or BTEQ command:'
>>> s.sendline('quit;')
6
>>> s.prompt()
False
>>> s.PROMPT='[PEXPECT]# '
>>> s.prompt()
False
>>> s.sync_original_prompt()
True
>>> s.prompt()
False
As per my understanding after s.sync_original_prompt()
, PROMPT
variable should reset to initial prompt, which is [PEXPECT]#
here, and s.prompt()
should result in True
. But it doesn't. Can anybody please tell me how to reset PROMPT
variable to original prompt? and how to use sync_original_prompt
attribute?
Thanks.
The initial
s.PROMPT
(a regexp string) is actually'\\[PEXPECT\\][\\$\\#] '
, not[PEXPECT]#
. I'd suggest you write like this:sync_original_prompt()
should be used like this: