Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import paramiko
- import sys
- import os
- import subprocess
- import time
- import datetime
- import cmd
- now = datetime.datetime.now()
- buff = ''
- resp = ''
- ini_path = '/home/rajesh/python/Imagecopy'
- os.makedirs(ini_path)
- with open('imagecopt.txt') as f:
- for line in f:
- line = line.strip()
- try:
- line = line.strip()
- dssh = paramiko.SSHClient()
- dssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- dssh.connect(line, username='*****',password='&&&&&&')
- chan = dssh.invoke_shell()
- output = chan.recv(1000)
- print output
- print"SSH connection established to %s" % line
- sftp = dssh.open_sftp()
- sftp.put('/home/rajesh/python/test.txt','Flash:')
- sftp.close()
- #resp = chan.recv(9999)
- print line, "Reachable ~ Command Executed"
- dssh.close()
- fin_path = os.path.join(ini_path, line)
- fp=open(fin_path + '.txt',"w")
- fp.write(resp)
- fp.close()
- except Exception as e:
- print line, "ERROR: ", e
Add Comment
Please, Sign In to add comment