我想從linux(遠程機器)複製目錄到windows(本地機器)。你們可以請告訴我這樣做的命令嗎?如何從linux(遠程系統)複製目錄到windows(本地系統)
示例:從 「/家/ TMP」 到 「C:\ TEMP」
我想從linux(遠程機器)複製目錄到windows(本地機器)。你們可以請告訴我這樣做的命令嗎?如何從linux(遠程系統)複製目錄到windows(本地系統)
示例:從 「/家/ TMP」 到 「C:\ TEMP」
有使用工具的文件夾壓縮成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();
}
}
使用SFTP客戶端等http://openssh.en.softonic.com/。還是一個非常基本的問題。在詢問之前應該已經做了一些搜索
一個選項是通過ssh服務器。爲此,你必須在Linux系統上安裝ssh服務器(用於Ubuntu的openssh)和窗口(例如:winscp)。之後,您可以通過scp命令傳輸文件。查看詳細Transferring files over SSH
我只使用scp cmd,但我不知道如何給目的地 – sasuke
你可以使用ssh服務器 – nKandel
Yuu應該指出你卡在哪裏。你有沒有訪問過Linux機器?如果是這樣,怎麼樣?等 – fedorqui