简体   繁体   中英

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/");

But how is the syntax to copy all files inside the /home/surendra/Desktop directory ?

Did you try wild card option? like 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/"});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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