批量执行命令
来源:互联网 发布:php搭建好显示http500 编辑:程序博客网 时间:2024/06/05 05:46
#-*- coding: utf-8 -*-#!/usr/bin/python import paramikoimport threadingdef ssh2(ip,username,passwd,cmd): try: ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(ip,22,username,passwd,timeout=5) for m in cmd: stdin, stdout, stderr = ssh.exec_command(m)# stdin.write("Y") #简单交互,输入 ‘Y’ out = stdout.readlines() #屏幕输出 for o in out: print o, print '%s\tOK\n'%(ip) ssh.close() except : print '%s\tError\n'%(ip)if __name__=='__main__': cmd = ['cal','echo hello!']#你要执行的命令列表 username = "" #用户名 passwd = "" #密码 threads = [] #多线程 print "Begin......" for i in range(1,254): ip = '192.168.1.'+str(i) a=threading.Thread(target=ssh2,args=(ip,username,passwd,cmd)) a.start()
0 0
- 批量执行命令
- 批量ssh执行命令
- 批量执行redis命令
- sh, 批量执行Linux命令
- sh, 批量执行Linux命令
- 用脚本批量执行redis命令
- 使用脚本批量执行GOGO命令
- 用脚本批量执行redis命令
- 批量远程执行shell命令工具
- Linux多台主机批量执行命令
- 多台机器批量执行命令
- Redis从文件中批量执行命令
- pyqt远程批量执行Linux命令程序
- expect无信任远程批量执行命令
- hbase-shell批量命令执行脚本
- Spark-shell批量命令执行脚本
- hive-shell批量命令执行脚本
- HGDB批量执行psql命令的脚本
- C#_WinForm_打开一个进程、文件等.
- 深入探索透视投影变换
- 将一个Bitmap 的内容存到file中
- Java常用工具类整理一
- ios 第三方库总结
- 批量执行命令
- 对象 组合 方法
- 数组及高维数组
- Android中的Handler
- Leaflet--建设移动设备友好的互动地图
- 20140710收盘小结
- Sequoiadb 测试体验系列之二 – shell 控制台初探
- Android中FTP服务器、客户端搭建以及SwiFTP、ftp4j介绍
- php 使用正则表达式删除多余的空格