Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import sys
- import paramiko
- import getpass
- import socket
- from multiprocessing import Pool
- def processFunc(hostname):
- handle = paramiko.SSHClient()
- handle.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- handle.connect(hostname, username=user, password=pw)
- print("child")
- stdin, stdout, stderr = handle.exec_command("show clock")
- cmdOutput = ""
- while True:
- try:
- cmdOutput += stdout.next()
- except StopIteration:
- break
- print("Got output from host %s:%s" % (hostname, cmdOutput))
- handle.close()
- user = "sup"
- f= open('csip.txt','r')
- hostnames = []
- for line in f:
- hostname = line.strip()
- hostnames.append(hostname)
- pw = getpass.getpass("Enter ssh password:")
- if __name__ == "__main__":
- pool = Pool(processes=4)
- pool.map(processFunc, hostnames, 1)
- pool.close()
- pool.join()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement