I’m using the Paramiko module to log into a server (ssh on some and sftp on others). I can get text and log files from specific folders on the server no problem. But there are many sub-directories that have .txt and .log files. I read some where that the get method will not accept (*.txt). Does anyone know a way around this. Here is the code that I’m currently using to log into a server and get a specific log:
import paramiko
import sys
import os
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('10.5.48.74', username='root', password='******')
ftp = ssh.open_sftp()
ftp.get('/var/opt/crindbios/log/crindbios.log', '.')
ftp.close()
Acquire a list of files with the following script. Then iterate over the list with http://ftp.get
It is what dustyprogrammer proposed: On the remote server you apply shell commands to acquire the file list. Then you postprocess the list with python.
To download you have to create a new filepath for each file – download to directory as you proposed doesn’t work (for me).