我想通过SSH登录到Exchange Server并执行MML(人机语言)命令。我能够成功登录,但无法执行MML命令。
我的代码:
import paramiko
ssh = paramiko.SSHClient()
ssh.load_system_host_keys()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('10.200.220.3', port=22, username='USER', password='SYSTEM')
stdin, stdout, stderr = ssh.exec_command("ZUSI;")
opt = stdout.readline()
opt = "".join(opt)
print(opt)
预期结果:
WORKING STATE AND RESTART HANDLING COMMAND <US_>
< ZUSI;
LOADING PROGRAM VERSION 27.56-2
EXECUTION STARTED
DXT A JED1H1 2019-01-29 16:59:44
WORKING STATE OF UNITS
UNIT PHYS STATE LOCATION INFO
OMU-0 0000 SP-EX -
OMU-1 0001 WO-EX -
CCSU-0 0020 WO-EX VMU-0 -
CCSU-1 0021 WO-EX VMU-1 -
CCSU-2 0022 WO-EX VMU-2 -
CCSU-3 0023 SP-EX VMU-3 IDLE
CMM-0 0004 WO-EX VMU-0 -
CMM-1 0005 SP-EX VMU-1 -
TAS-0 0050 WO-EX VMU-0 -
TAS-1 0051 WO-EX VMU-1 -
TAS-2 0052 WO-EX VMU-2 -
TAS-3 0053 SP-EX VMU-3 IDLE
TGS-0 0060 WO-EX VMU-0 -
TGS-1 0061 SP-EX VMU-1 -
VMU-0 0082 WO-EX -
VMU-1 0083 WO-EX -
VMU-2 0084 WO-EX -
VMU-3 0085 WO-EX -
SWU-0 WO-EX 1A001-00-8 CNW-0 -
SWU-1 WO-EX 1A001-00-9 CNW-1 -
SWU-60 WO-EX 1A001-00-8 EMB-0 -
SWU-61 WO-EX 1A001-00-9 EMB-1 -
实际结果:
Traceback (most recent call last):
File "C:/Users/saleh.aslam/PycharmProjects/Next/Multiple Command Output.py", line 8, in <module>
stdin, stdout, stderr = ssh.exec_command("ZUSI;")
File "C:\Users\saleh.aslam\AppData\Local\Programs\Python\Python37\lib\site-packages\paramiko\client.py", line 499, in exec_command
chan.exec_command(command)
File "C:\Users\saleh.aslam\AppData\Local\Programs\Python\Python37\lib\site-packages\paramiko\channel.py", line 72, in _check
return func(self, *args, **kwds)
File "C:\Users\saleh.aslam\AppData\Local\Programs\Python\Python37\lib\site-packages\paramiko\channel.py", line 257, in exec_command
self._wait_for_event()
File "C:\Users\saleh.aslam\AppData\Local\Programs\Python\Python37\lib\site-packages\paramiko\channel.py", line 1208, in _wait_for_event
raise e
paramiko.ssh_exception.SSHException: Channel closed.
Process finished with exit code 1