Hot For Coding
cwRsync命令行带密码

full

cwRsync是基于Win平台的rsync解决方法,但经过测试有一个选项参数--password-file始终都不起作用

@ECHO OFF
D:
cd "\Program Files (x86)\cwRsync\bin"
rsync ^
-vzrtopg ^
--progress ^
--delete ^
/cygdrive/d/Workspace/Aptana/demo/ ^
user@192.168.1.48::demo ^
--port=7876 ^
--password-file=/cygdrive/d/Workspace/Aptana/demo/rsyncd/passwd.txt ^
--exclude-from=/cygdrive/d/Workspace/Aptana/demo/rsyncd/filter.txt
pause

运行总是提示

password file must be owned by root when running as root
continuing without password file
Password:

Win上哪有root账户?难道是权限问题,把passwd.txt的权限捣鼓了一通,最终得出结论行不通。只好改用其它方法,一番研究后觉得可以这么干,可以在批处理文件中定义一个密码变量,等于把密码写在bat文件中,如

@ECHO OFF
SET RSYNC_PASSWORD=8532
D:
cd "\Program Files (x86)\cwRsync\bin"
rsync ^
-vzrtopg ^
--progress ^
--delete ^
/cygdrive/d/Workspace/Aptana/demo/ ^
user@192.168.1.48::demo ^
--port=7876 ^
--exclude-from=/cygdrive/d/Workspace/Aptana/demo/rsyncd/filter.txt
pause

以上代码测试通过!

TITLE: cwRsync命令行带密码

LINK: https://www.qttc.net/431_cwrsync_command_line_password.html

NOTE: 转载内容请注明出处