1
시스코 장치에서 사용자 이름, 암호 및 암호를 확인하는 python 스크립트를 작성하려고합니다.잘못된 모듈을 사용하고 있습니까? pxssh
스크립트가 장치에 로그인했지만 쉘 프롬프트를 설정 및 설정하려고합니다. pxssh가 아닌 표준 pexpect만을 사용해야합니까? 나는 이것을 시도했지만 'if'문이 기대와 잘 어울리는 것 같지 않습니다. 어떤 충고라도 크게 도움이 될 것입니다.
Exception:
could not set shell prompt
unset PROMPT_COMMAND
^
% Invalid input detected at '^' marker.
3750_core#PS1='[PEXPECT]\$ '
3750_core#set prompt='[PEXPECT]\$ '
^
% Invalid input detected at '^' marker.
코드 :
def check_creds(host, user, password, en_passwd):
global success
global failure
try:
ssh = pxssh.pxssh()
ssh.login(host, user, password, en_passwd)
if ssh.prompt(PRIV_EXEC_MODE):
print 'privilege mode creds work'
ssh.logout()
success = True
if ssh.prompt(USER_EXEC_MODE):
print('username and password are correct')
ssh.sendline('enable')
ssh.sendline(en_passwd)
if ssh.prompt(PRIV_EXEC_MODE):
print 'enable password is correct'
ssh.logout()
success = True
else:
print 'enable password is incorrect'
ssh.logout()
failure = True
except pxssh.ExceptionPxssh, fail:
print str(fail)
failure = True
exit(0)