I am using Python 2.7 with library paramiko
. I want to find the latest modified file in the remote machine. Here is my code:
First, I import the required libraries,
import paramiko
Second, I set up the ssh client and sftp,
s = paramiko.SSHClient()
s.set_missing_host_key_policy(paramiko.AutoAddPolicy())
s.connect("XXX.XXX.XXX.XX",22,username="NAME",password='PW',timeout=4)
sftp = s.open_sftp()
Afterwards, I have no idea how I can traverse the directory /home/image/
to find out the latest modified file in the remote machine.
I only know how to find it in local, like:
file= max(glob.iglob(os.path.join('/home/image/','*.png')), key=os.path.getmtime).replace("//","/")
I am asking for help how can I find out the latest modified file in the remote machine. Thank you.