[英]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.