简体   繁体   English

如何复制远程目录中的所有文件?

[英]How to copy all files inside a remote directory?

The command to copy a single file remotely is Runtime.getRuntime().exec("sshpass -p sbsiz scp '/home/surendra/Desktop/remote_backup.txt' root@192.168.59.115:/home/"); 远程复制单个文件的命令是Runtime.getRuntime().exec("sshpass -p sbsiz scp '/home/surendra/Desktop/remote_backup.txt' root@192.168.59.115:/home/");

But how is the syntax to copy all files inside the /home/surendra/Desktop directory ? 但是,复制/home/surendra/Desktop目录内的所有文件的语法如何?

Did you try wild card option? 您尝试过通配符选项吗? like scp /local-directory/* root@<some-host>:/remote-directory scp /local-directory/* root@<some-host>:/remote-directory

In your case run following. 在您的情况下,请执行以下操作。

Runtime.getRuntime().exec(new String[] {"/bin/sh","-c", "sshpass -p sbsiz scp '/home/surendra/Desktop/*' root@192.168.59.115:/home/"});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM