#!/usr/bin/python3
# -*- coding:utf-8 -*-
import paramiko
import time ssh = paramiko.SSHClient()
key = paramiko.AutoAddPolicy()
ssh.set_missing_host_key_policy(key) def execute(addr): ssh.connect(addr, 22, 'test', '', timeout=200)
ssh_shell = ssh.invoke_shell() for script in scripts:
ssh_shell.send(script)
time.sleep(0.1) if __name__ == '__main__': # 要批量执行脚本的设备
devices = ['10.1.3.161', '10.1.3.162', '10.1.3.163'] # 要批量执行的脚本
scripts = ['sys\n', 'sys sw\n', 'q\n', 'save\n', 'Y\n'] for device in devices:
execute(device)

Python实现批量执行华为交换机脚本的更多相关文章

  1. 自动化工具 Python 调 Jmeter 执行参数化 jmx 脚本

    烦透了jmeter输入如下鬼命令: Jmeter -n -t {tmpjmxfile} -l {csvfilename} -e -o {htmlreportpath} 尤其是{htmlreportpa ...

  2. Appium+Python之批量执行测试用例

    思考:当存在多个脚本,每个脚本中有多条测试用例时,我们该如何批量执行呢?分析:首先创建2个测试用例脚本(.py文件),每个脚本有2条测试用例,然后批量执行全部测试用例 #Test_01.py # co ...

  3. windows 批量执行命令的脚本

    因为老板一个电话,我的国庆节就没了....,老板要我写个东西,能批量执行500台windows的命令并返回结果,虽然完成以后是非常的简单,但是因为我走了很多弯路,一开始想用powershell来写,后 ...

  4. python+selenium 批量执行时出现随机报错问题【已解决】

    出现场景:用discover方法批量执行py文件,出现随机性的报错(有时a.py报错,有时b.py报错...),共同特点:均是打开新窗口后,切换最新窗口,但定位不到新窗口的元素,超时报错.由于个人项目 ...

  5. python自动化--批量执行测试之生成报告

    一.生成报告 1.先执行一个用例,并生成该用例的报告 # -*- coding: utf-8 -*- from selenium import webdriver from selenium.webd ...

  6. python中command执行shell命令脚本方法

    在Python中有一个模块commands也很容易做到以上的效果.看一下三个函数:1). commands.getstatusoutput(cmd)用os.popen()执行命令cmd, 然后返回两个 ...

  7. python远程批量执行命令

    #!/usr/bin/env python#-*- coding:utf-8 -*- from multiprocessing import Process,Poolimport time,param ...

  8. python mysqldb批量执行语句executemany

    MySQLdb提供了两个执行语句的方法,一个是execute(),另一个是executemany() execute(sql) 可接受一条语句从而执行 executemany(templet,args ...

  9. [ Python - 13 ] 批量管理主机必备模块

    批量管理程序必备模块 optparse configparser paramiko optparse模块 简介:        optparse模块主要用来为脚本传递命令参数功能 使用步骤: 1. i ...

随机推荐

  1. requests中text,content,json之间的区别

    response.text : 返回一个字符串\n",content : 返回二进制\n",json() : 返回对象"

  2. 对js库的调研研究------引用

    1. 引言 从以下几个方面来阐述这个问题: 特性. 稳定性. 性能. 包生态. 社区. 学习曲线. 文档. 工具. 发展历史. 团队. 兼容性. 趋势. 2.概述 & 精读 特性 当你调研一个 ...

  3. new/delete和malloc/free区别与联系

    1.基本概念 malloc/free (1).函数原型及说明 void *malloc(long NumBytes): 该函数分配了NumBytes个字节,并返回了指向这块内存的指针.如果分配失败,则 ...

  4. Luogu P5469 [NOI2019]机器人 (DP、多项式)

    不用FFT的多项式(大雾) 题目链接: https://www.luogu.org/problemnew/show/P5469 (这题在洛谷都成绿题了海星) 题解: 首先我们考虑,一个序列位置最右边的 ...

  5. sar性能监控

    1.安装sar: yum -y install sysstat 第一次使用sar命令会提示如下错误:“无法打开 /var/log/sa/sa13: 没有那个文件或目录”. 这里的值13是当天的日期,如 ...

  6. 修改docker下mysql配置

    1.在/home/smile/docker/mysql/config/目录下增加一个文件 my.cnf # Copyright (c) , Oracle and/or its affiliates. ...

  7. bootstrap-table export导出问题

    引入方式如上图,首先是,bootstrap.min.js,其他 Bootstrap Table 官网 bootstrap-table.min.js  // 表格 bootstrap-table-zh- ...

  8. kafka-manager怎么查看topic里的数据量

    https://jingyan.baidu.com/article/eb9f7b6d367679869364e8d4.html

  9. linux修改时区为东八时区,北京时间,上海时间

    ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime echo "Asia/Shanghai" > /etc/tim ...

  10. Deepin 系统下设置Apache虚拟主机站点

    1,在 var/www/html 文件夹中创建一个文件夹,命名为 a ,用来作为我们的PHP项目文件夹. 2,找到 etc/apache2/sites-available 文件夹,在文件夹中创建一个站 ...