Remote Copy File API

Discussion in 'Java' started by Prime, Aug 10, 2005.

  1. Prime

    Prime Guest


    My project involves copying files from one Host to another Host located
    on the same network of, currently, Solaris machines.

    Is there a library or API set that performs tasks similar to Unix's
    "rcp host1:<filename> host2:<filename>"

    Something like:

    RemoteFile r = new RemoteFile(host2, path, filename); ??

    I want to do this in Java instead of using Shell Scripts for obvious
    reasons. I've thought of looking into Jakarta by Apache for FTP, but
    we can't get into storing/saving the password for the FTP username.

    Any ideas or recommendations?

    Thank you!
    Prime, Aug 10, 2005
    1. Advertisements

  2. Andrew Thompson, Aug 10, 2005
    1. Advertisements

  3. Prime

    Roedy Green Guest

    I have not used Solaris, but in some remote file systems, the remote
    machines look just like additional drives. You access them the same
    way you would local drives or drives on other machines on your local
    lan with some file naming convention. An ordinary file copy will

    see to do various types
    of file copy in Java.

    If you don't have that, or don't have security clearance to write
    files on the remote machines, you can get stuff via HTTP, but you
    can't very well put it that way. Even getting presumes some HTTP
    server is running on the source machine and is willing to send it to
    you. You need FTP to upload. See

    And then you will need an account and password to upload the FTP with
    rights to leave the file where you want to.

    Another approach is to use Rsync. See

    I am amazed how i/o to remote machines has not been made seamless once
    you have satisfied the security requirement. It should look just like
    local i/o.

    For other options, see

    In any case you are the man the middle copying from source to yourself
    then from yourself to target.
    Roedy Green, Aug 11, 2005
  4. Prime

    Jeff Schwab Guest

    On Solaris (with NFS), the equivalent is to mount the remote filesystem
    on the local machine. Machines on the same local network are often
    configured this way when they're first set up, such that every host's
    files are mounted at /export/<hostname> on other local machines.

    Rcp has largely been superceded by scp. A couple of minutes on Google
    turned up several Java scp clients, but none of them looked both usable
    and free. Here are the docs for one commercially available client that
    seems to match the kind of interface you would like.
    Jeff Schwab, Aug 11, 2005
  5. If you want rcp, then just use Runtime.exec() to start rcp.
    What reasons should that be? rcp requires super-user rights. The client
    needs to use a source port > 511 and < 1024. You would have to run the
    VM with such rights, just because of some rcp protocol implementation
    inside your Java application.

    BTW: rcp was never formally specified. It is basically rsh (also not
    formally specified), which is in turn basically rlogin (that one you get
    an RFC for ...), but with the server daemon on port 514, instead of 513.

    If you want to implement it, get some rcp C source code and clone it in

    Thomas Weidenfeller, Aug 11, 2005
  6. Prime

    Prime Guest

    First off thank you for all the responses!

    The bulk of my project is about file manipulation, copying/deleting,
    archiving/extracting, obtaining file size, and all this can be done,
    but not to remote hosts, which is why the initial use of shell scripts.

    The reasons I would prefer not to use shell scripts is because down the
    road we are switching from Solaris to a newer version of Red Hat Linux.
    Most likely the commands will still be the same, but using scripts
    does take away from being 100% Platfrom Independant. Also, it puts the
    strain on the Operating Environment to do the work I would like my
    program to do. Lastly, if something went wrong in the beginning of the
    script, (file permissions error, file not found error, anything), my
    program would not know until after the script has run. This forces me
    to do a large amount of error checking afterward that a try-catch block
    would catch immediately.

    Unfortunately, no remote hosts are mounted onto the /export/* folder.

    We have been looking into purchasing an FTP library that would do these
    manipulations, however, some of us have issues with storing the
    password or hardcoding it. It's sort of a conundrum, we want secure,
    remote file functions, but we want to do it by bypassing the password.
    Also, we would probably need client software to run on remote hosts.

    Thanks again for all your help, I will be checking those links, and any
    more information would be greatly appreciated!
    Prime, Aug 11, 2005
  7. Prime:

    I started a file transfer project a while back. It works but could use
    some updating and feature addition. If you want the source, email me.


    email s/nospam/knute/
    Knute Johnson, Aug 11, 2005
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.