0

I am trying to copy a directory from linux (remote machine) to windows (local machine). Can you guys please tell me the command to do that.

Example: from "/home/tmp" to "C:\TEMP"

sasuke
  • 595
  • 1
  • 5
  • 15

3 Answers3

4

One option is through ssh server. For that you have to install ssh server in linux system (openssh for ubuntu) and on window (for eg: winscp) also. After that you can able to transfer file throught scp command. For detail Transferring files over SSH

Community
  • 1
  • 1
nKandel
  • 2,543
  • 1
  • 29
  • 47
1

Have a utility to zip the folder into a zip file (on your linux node) using:

zip -r temp.zip /home/tmp

After that transfer it to your local as a simple single file using sftp. And at last unzip it on windows machine (using 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(); 
}
}
solvesak
  • 166
  • 1
  • 13
0

use sftp client like http://openssh.en.softonic.com/. Still a very basic question. Should have done some search before asking

abhinav
  • 1,252
  • 10
  • 27