Skip to content Skip to sidebar Skip to footer

Using Wildcards In Filename In Scp In Python

I want to execute a simple scp command in a python script, copying files following a certain name pattern. I'm executing the following command: filename = '\*last_processed_date\*.

Solution 1:

This works on my system:

host = 'test@100.41.14.27'
filename = '*last_processed_date*.txt'
rpath = '/home/test/test2/test3'
lpath = self.unprocessed_file_dir
command = 'scp %s:%s/%s %s' % (host, rpath, filename, lpath)
os.system(command)

If it gives you an error, try this on from the terminal first:

ssh test@100.41.14.27 ls /home/test/test2/test3/*last_processed_date*.txt

Post a Comment for "Using Wildcards In Filename In Scp In Python"