简体   繁体   English

使用 RCP 或 FTP 将文件从远程 unix 机器复制到本地 windows 机器上

[英]Using RCP or FTP to copy files from a remote unix machine onto a local windows machine

I'm trying to write a piece of code that uses a ProcessBuilder to transfer a file on a remote UNIX machine onto the local Windows machine.我正在尝试编写一段代码,该代码使用 ProcessBuilder 将远程 UNIX 机器上的文件传输到本地 Windows 机器上。 On a brief bit of research I've found that either RCP or FTP should be a suitable thing to use.在简短的研究中,我发现 RCP 或 FTP 应该是合适的使用方法。

Having done some research on the RCP command, I found instructions for copying files from a UNIX to windows machine, but they don't seem to work.在对 RCP 命令进行了一些研究之后,我发现了将文件从 UNIX 复制到 windows 机器的说明,但它们似乎不起作用。 The command I was told to use was:我被告知使用的命令是:

rcp -r unixhost.user:/example/directory C:\Directory

However using this told me that C: was not a host.但是使用它告诉我 C: 不是主机。 I tried it with the IP address, localhost, the alias of the windows pc in the hosts file but none of these worked, it either said permission denied or it could not connect to the host.我尝试使用 IP 地址、localhost、hosts 文件中 windows pc 的别名,但这些都不起作用,它要么说权限被拒绝,要么无法连接到主机。 Having looked up ftp it seems that would be another viable option.查找 ftp 之后,这似乎是另一个可行的选择。 I'm not sure if I can execute a command using ProcessBuilder to successfully achieve this via FTP.我不确定是否可以使用 ProcessBuilder 执行命令以通过 FTP 成功实现此目的。

Would rcp or ftp be more suitable for this task? rcp 或 ftp 会更适合这项任务吗? And how would I go about using them?我将如何使用它们?

EDIT: To clarify, the script/batch file will be running on the Windows machine and pulling the files from the UNIX machine to windows.编辑:澄清一下,脚本/批处理文件将在 Windows 机器上运行,并将文件从 UNIX 机器拉到 windows。

It may be possible to escape the colon in the destination part.可以在目标部分转义冒号。 Have you tried quoting the destination?你试过引用目的地吗?

rcp -r unixhost.user:/example/directory "C:\Directory"

It's been a while since I've done any command-line stuff on windows, but I remember the backslash character always being problematic.我已经有一段时间没有在 windows 上执行任何命令行操作了,但我记得反斜杠字符总是有问题。 You may need to use forward slashes in the destination, since the rcp command is consuming the command line.您可能需要在目标中使用正斜杠,因为rcp命令正在使用命令行。 You may also be able to use the backslash as an escape character, so you might try the following:您也可以使用反斜杠作为转义字符,因此您可以尝试以下操作:

rcp -r unixhost.user:/example/directory C\:/Directory

If that won't work, you can explicitly set the current drive letter before calling the rcp command.如果这不起作用,您可以在调用 rcp 命令之前显式设置当前驱动器号。 If you're using a batch file, try the following two lines:如果您使用的是批处理文件,请尝试以下两行:

c:
rcp -r unixhost.user:/example/directory \Directory

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Java将文件从本地窗口机器复制到远程Windows机器 - Copy files from local window machine to remote windows machine using java 在Windows机器上使用Java Code将本地文件复制到Unix Server? - Copy local file to Unix Server using java Code on windows machine? 使用 java.nio.file.Files.copy() 将文件从 Linux 复制到 Windows 远程机器 - Copy a file to a Windows remote machine from Linux using java.nio.file.Files.copy() 从Broker(Unix)将文件写入Windows计算机 - Writing files to windows machine from Broker (Unix) 在Java FTP中-是否可以在不使用本地文件的情况下使用ftp将文件压缩到远程位置? - In Java FTP-Can we compress a file in remote location using ftp, without bringing the file to local machine? 如何使用Java将文件从ftp服务器下载到本地计算机 - How to download a file from ftp server to local machine using java 将远程服务器目录复制到本地计算机 - Copy remote server directories to local machine 批处理文件可以从本地计算机执行到本地计算机的(本地)Java代码吗? - Can batch files execute (local) Java code from a local machine to a remote machine 使用JSch将一个文件从远程计算机复制到另一台远程计算机 - Using JSch to copy one file from remote machine to another remote machine 如何从 windows 机器到 linux 机器的 FTP 文件 - how to FTP file from windows machine to linux machine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM