我必须在Java中执行rdiff备份命令。我用Runtime巧妙地尝试执行从本地到远程的备份命令。
我需要使用远程模式,因为我无法连接到standart端口22。
由于相同的命令在windows中工作,而远程命令拒绝工作,所以我尝试了这样的方法:
Runtime r = Runtime.getRuntime();
Process proc = r.exec("C:/rdiff/rdiff-backup.exe "
+"--remote-schema="
+"ssh -C -p16000 %s rdiff-backup --server "
+"C:/Users/Utilisateur/Desktop/backup "
+"user@xxx.net::/var/backup");获取此错误:致命错误:错误的命令行选项:选项-C未被识别
或
String[] commandLine= {"C:/rdiff/rdiff-backup.exe",
"C:/Users/Utilisateur/Desktop/backup",
"\"-p 16000 user@xxx.net\"",
"::/var/backups"};
Runtime r = Runtime.getRuntime();
Process proc = r.exec(commandLine);获取此错误:致命错误:开关丢失或参数数目错误
谢谢你的帮助..。
发布于 2016-05-09 13:15:52
在java中,您使用的第一个方法是ok。但是您的命令行是错误的- ssh -C不是一个正确的命令。确保命令在shell中工作,然后在第一个方法中使用它。
https://stackoverflow.com/questions/37116552
复制相似问题