Java runtime.exec invoke linux SCP command copy directory on remote machine failed __ function

Source: Internet
Author: User
Tags scp command

1. Requirements: Need to copy from A machine directory to B machine, and then from B machine copy directory to C machine.

2. Implementation: Run a Java program on the B-Machine and invoke the Linux SCP command to implement it.

3. Question:

Copy directory from a machine to B machine success, but from B machine copy directory to C machine failed, almost the same format command, but the command can be executed directly in Linux, with Runetime.exec call is an error.

Such as:

//This command can be successfully executed .

Runtime.exec ("Scp-r root@192.168.1.11:/ps_test/indexes/*/ps_temp/indexes/");

//The command failed to execute

Runtime.exec ("Scp-r/ps_temp/indexes/* root@192.168.1.13:/ps_test/indexes/");

4. Solution:

//Change the second command to:

Runtime.exec ("Scp-r/ps_temp/indexes root@192.168.1.13:/ps_test/indexes/");

That is, the "/*" can be removed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.