I'm using Paramiko to connect to a server via SSH, run a command to generate a report, then download the report to my local computer. Everything seems to work fine without an error, but the resulting file is blank on my local computer. I'm using Python 2.7 and the latest version of Paramiko. The file that I'm trying to download is a .csv . I've verified that the file contains data server-side.
The code I am using is below:
try:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname, username=user_name, key_filename=key_file)
except:
print 'error connecting'
try:
stdin, stdout, stderr = ssh.exec_command(report_cmd)
except:
print 'error generating report'
try:
sftp = ssh.open_sftp()
sftp.get(source_str, dest_str)
except:
print 'failed to DL file' + str(sys.exc_info())
ssh.close()