Remote file system tools for data manipulation between remote and local host (cp, mv, ls, rm,..) written in Python3.
This package provides you executables pcp
, pls
, pmv
,..., which enables you to do painless data operations on remote/between remote and local host using SFTP/FTP/FTPS/SMB12(SMB version 1 or 2)/SMB23(SMB version 2 or 3)/FS(local file system) protocols.
Furthermore, you can enable data re-encoding during data transfer (CRLF/LF and character re-encoding).
The rfstools
tool can be installed using pip
from the PyPI public registry.
pip install rfstools
The documentation can be found in autogenerated repository rfstools-docs.
Arguments can be passed to rfstools
commands in multiple ways - configuration file, environment variable, and standard command line argument.
If an argument is specified in more than one place, then the command line argument overrides the environment variable which overrides the config file value which overrides the default value.
Arguments that start with '--' can be set in a config file - /etc/rfstools.conf or ~/.rfstools.conf or specified via -c. Config file syntax allows: key=value, flag=true, stuff=[a,b,c] (for details, see syntax at https://goo.gl/R74nmi).
Details about concrete commands can be found in rfstools-docs/commands.
In further subchapters, there are examples of solving some of the basic tasks using this tool. Only the first chapter contains the configuration file setup...in the others, it can be done analogically.
First of all, we need to set up the configuration file.
cat > /some-path/rfstools.conf << EOF
connection-type=SMB12
# For SMB we always need to say, which remote folder we use.
service-name=special-folder
host=speciserver-smb.cz
username=speciman
password=mysecret
EOF
After that, we set up an environment variable RFSTOOLS_CONFIG
, so the tool knows, which configuration file should it use.
export RFSTOOLS_CONFIG=/some-path/rfstools.conf
Finally, we run
pcp r:/some-path2/file ./
pcp r:/etc/*.conf ./
pls r:/some-path/*/
pcp -r r:/folder ./
pmv r:/tmp/* /tmp
pcp r:/file1 /file2 r:/target-folder
prm -r r:/**/*.tmp
pls -p r:/some-path | grep "^.*/SOME_REGEX$" | xargs pcp -t /target-folder
export RFSTOOLS_REMOTE_CRLF=TRUE
pcp -X r:/crlf-file ./lf-file
export RFSTOOLS_REMOTE_ENCODING=UTF16
pcp -X ./utf8-file r:/utf16-file