# more ddve.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
# filename: pexpect_test.py
import threading
import paramiko
import subprocess
import sys
ip = "IP地址"
user = "sysadmin"
passwd = "密码"
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(ip,22,username=user,password=passwd)
remote_connection = client.invoke_shell()
output = remote_connection.recv(1000)
print output
remote_connection.send("alerts show current\n");
output = remote_connection.recv(5000)
print output
[root@netman py]# python ddve.py
Last login: Mon Dec 17 19:19:44 CST 2018 from 10.20.0.202 on gui
alerts show current
[root@netman py]#
文章评论