0

So i am trying to send a certain file from my local server to another server. I am able to send the file if i know the file with exact name. Bur what i actually want to do is pick up a file having a matching name and send the same file over.

For example my filename is filename_: test_file_20190918 i want to pick up all the file matching test_file_*

Here's what i am trying to do, but it doesn't seem to be working

import paramiko
ssh=paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname='host_name',username='username',password='pwd',port=22)
sftp_client=ssh.open_sftp()

sftp_client.put("/home/mylocation/test_file_*",'/incoming/test_file_send*')

sftp_client.close()
ssh.close()

1 Answers1

0

Paramiko does not support wildcards.

You have to find the right file yourself, before calling SFTPClient.put.

See Get a filtered list of files in a directory.


Obligatory warning: Do not use AutoAddPolicy, unless you do not care about security. You are losing a protection against MITM attacks this way.
For a correct solution, see Paramiko "Unknown Server".

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992