I was using parallelSSHClient - copy_to_file
The code was like below,
greenlets = client.copy_file('/tmp/logs', '/home/sugan/remote_copy/', recurse=True)
From /tmp/logs, I'm copying to my home path(/home/sugan) under the name 'remote_copy'.
The copying is as expected but during copying the destination path is starting with '/' then after '/' what is the first directory (in my case it 'home') a empty directory 'home' is getting creating in my home path(/home/sugan)
output:
-rw-r--r-- 1 sugan sugan 420 Jun 19 00:15 sftp.py
drwxr-xr-x 3 sugan sugan 21 Jun 19 00:17 home
pwd: /home/sugan
Consider now my script is changed as,
greenlets = client.copy_file('/tmp/logs', '/opt/user1/remote_copy/', recurse=True)
My home path is - /home/sugan but I'm copying to /opt/user1. So now when I executed the script. The script creates a empty directory 'opt' in my home path(/home/sugan).
output:
-rw-r--r-- 1 sugan sugan 420 Jun 19 00:19 sftp.py
drwxr-xr-x 3 sugan sugan 21 Jun 19 00:22 opt
pwd: /home/sugan
So whatever destination path is given and the path startswith '/' then the first directory of the path is getting created in home path. If a same directory already exists in home path then it is ignored.
And if the destination path is a relative path from home then the parallelSSHClient.copy_file works as expected.
My concern is generally we use absolute path for all... So each an empty directory is getting created in home.
|