I'm having a problem with a ShoreTel voice switch, and I'm trying to use Paramiko to jump into it and run a couple commands. What I believe the problem might be, is that the ShoreTel CLI gives different prompts than the standard Linux $
. It would look like this:
server1$:stcli
Mitel>gotoshell
CLI> (This is where I need to enter 'hapi_debug=1')
Is Python still expecting that $
, or am I missing something else?
I thought it might be a time thing, so I put those time.sleep(1)
between commands. Still doesn't seem to be taking.
import paramiko
import time
keyfile = "****"
User = "***"
ip = "****"
command1 = "stcli"
command2 = "gotoshell"
command4 = "hapi_debug=1"
ssh = paramiko.SSHClient()
print('paramikoing...')
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname = ip, username = User, key_filename = keyfile)
print('giving er a go...')
ssh.invoke_shell()
stdin, stdout, stderr = ssh.exec_command(command1)
time.sleep(1)
stdin, stdout, stderr = ssh.exec_command(command2)
time.sleep(1)
stdin, stdout, stderr = ssh.exec_command(command4)
time.sleep(1)
print(stdout.read())
ssh.close()
print("complete")
What I would expect from the successful execution of this code, would be for the hapi_debug
level to be 1. Which means that when I SSH into the thing, I would see those HAPI debugs populating. When I do, I do not see those debugs.