简体   繁体   中英

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. On a brief bit of research I've found that either RCP or FTP should be a suitable thing to use.

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. 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. 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. Having looked up ftp it seems that would be another viable option. I'm not sure if I can execute a command using ProcessBuilder to successfully achieve this via FTP.

Would rcp or ftp be more suitable for this task? 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.

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. You may need to use forward slashes in the destination, since the rcp command is consuming the command line. 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. If you're using a batch file, try the following two lines:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM