Como posso enviar multiplos comandos para um servidor remoto usando python?
Eu tive de aprender python por motivos de estudo, decidi então tentar automatizar a coleção de informação dos consoles bacula.
Estou tentando usando o seguinte script, mas não tenho tido sucesso.
Poderiam me apontar onde estou errando?
HOST= 'server.name.com.br'
try:
s = pxssh.pxssh()
hostname = HOST
username = 'root'
password = 'xxxxxxx'
s.login(hostname, username, password)
s.sendline('bconsole') # run a command
s.prompt() # match the prompt
print(s.before) # print everything before the prompt.
s.prompt() # match the prompt
s.sendline('st') # run a command
s.prompt() # match the prompt
print(s.before) # print everything before the prompt.
s.prompt() # match the prompt
s.sendline('1') # run a command
s.prompt() # match the prompt
print(s.before) # print everything before the prompt.
s.prompt() # match the prompt
s.logout()
except pxssh.ExceptionPxssh as e:
print("pxssh failed on login.")
Muito obrigado pela atenção.