【问题标题】:How to copy a directory from linux(remote system) to windows(local system) [closed]如何将目录从linux(远程系统)复制到windows(本地系统)[关闭]
【发布时间】:2013-06-09 15:41:16
【问题描述】:

我正在尝试将目录从 linux(远程机器)复制到 windows(本地机器)。你们能告诉我执行此操作的命令吗?

示例:从“/home/tmp”到“C:\TEMP”

【问题讨论】:

  • 你可以使用ssh服务器
  • Yuu 应该指出你卡在哪里了。你访问过linux机器吗?如果是这样,怎么做?等等。

标签: unix


【解决方案1】:

使用以下工具将文件夹压缩成 zip 文件(在您的 linux 节点上):

zip -r temp.zip /home/tmp

之后,使用 sftp 将其作为简单的单个文件传输到您的本地。 最后在windows机器上解压(使用java.util.zip)。

 /**
 * Unzip it
 * @param zipFile input zip file
 * @param output zip file output folder
 */
public void unZipFolder(String zipFile, String outputFolder){

 byte[] buffer = new byte[1024];

 try{

    //create output directory is not exists
    File folder = new File(OUTPUT_FOLDER);
    if(!folder.exists()){
        folder.mkdir();
    }

    //get the zip file content
    ZipInputStream zis = 
        new ZipInputStream(new FileInputStream(zipFile));
    //get the zipped file list entry
    ZipEntry ze = zis.getNextEntry();

    while(ze!=null){

       String fileName = ze.getName();
       File newFile = new File(outputFolder + File.separator + fileName);

       System.out.println("file unzip : "+ newFile.getAbsoluteFile());

        //create all non exists folders
        //else you will hit FileNotFoundException for compressed folder
        new File(newFile.getParent()).mkdirs();

        FileOutputStream fos = new FileOutputStream(newFile);             

        int len;
        while ((len = zis.read(buffer)) > 0) {
        fos.write(buffer, 0, len);
        }

        fos.close();   
        ze = zis.getNextEntry();
    }

    zis.closeEntry();
    zis.close();

    System.out.println("Done");

}catch(IOException ex){
   ex.printStackTrace(); 
}
}

【讨论】:

    【解决方案2】:

    一个选项是通过 ssh 服务器。为此,您还必须在 linux 系统(openssh for ubuntu)和窗口(例如:winscp)上安装 ssh 服务器。之后,您可以通过 scp 命令传输文件。详情Transferring files over SSH

    【讨论】:

    • 我只使用 scp cmd 但我不知道如何给出目的地
    【解决方案3】:

    使用像 http://openssh.en.softonic.com/ 这样的 sftp 客户端。仍然是一个非常基本的问题。在询问之前应该做一些搜索

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-30
      • 1970-01-01
      • 2019-05-03
      • 2022-01-15
      • 2011-09-02
      相关资源
      最近更新 更多