在 paramiko 中找不到 Unifi 的命令 shell
Unifi's command not found with the paramiko's shell
我想给Unifi天线发送SSH命令,具体如下命令:set-inform http://unifi.<ip>:<port>/inform
。此命令在 Putty 中完全可用,但是当我使用以下代码时,我得到以下响应:
Resp:
Err: ash: set-inform: not found
我怀疑所选 shell 有误。
import paramiko
ip = 'XX.XX.XX.XX'
port = 22
username = 'XXX'
password = 'XXX'
try:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip, port, username, password)
stdin, stdout, stderr = ssh.exec_command("set-inform http://unifi.<ip>:<port>/inform")
outlines = stdout.readlines()
errors = stderr.readlines()
resp = ''.join(outlines)
respErrors = ''.join(errors)
print('Resp: '+resp)
print('Err: '+respErrors)# Output
except AttributeError:
print("Erreur inconnue" + stderr)
except TimeoutError:
print("Erreur de connexion")
我需要指定命令的路径。以下是要写的内容:
stdin, stdout, stderr = ssh.exec_command(" /usr/bin/mca-cli-op set-inform http://unifi.<ip>:<port>/inform")
您可以在这里看到整个项目:https://github.com/simbarras/unifiAdopter
我想给Unifi天线发送SSH命令,具体如下命令:set-inform http://unifi.<ip>:<port>/inform
。此命令在 Putty 中完全可用,但是当我使用以下代码时,我得到以下响应:
Resp:
Err: ash: set-inform: not found
我怀疑所选 shell 有误。
import paramiko
ip = 'XX.XX.XX.XX'
port = 22
username = 'XXX'
password = 'XXX'
try:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip, port, username, password)
stdin, stdout, stderr = ssh.exec_command("set-inform http://unifi.<ip>:<port>/inform")
outlines = stdout.readlines()
errors = stderr.readlines()
resp = ''.join(outlines)
respErrors = ''.join(errors)
print('Resp: '+resp)
print('Err: '+respErrors)# Output
except AttributeError:
print("Erreur inconnue" + stderr)
except TimeoutError:
print("Erreur de connexion")
我需要指定命令的路径。以下是要写的内容:
stdin, stdout, stderr = ssh.exec_command(" /usr/bin/mca-cli-op set-inform http://unifi.<ip>:<port>/inform")
您可以在这里看到整个项目:https://github.com/simbarras/unifiAdopter