Remote Copy File API

P

Prime

Hello,

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!
 
R

Roedy Green

Hello,

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!

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
work.

see http://mindprod.com/products.html#FILETRANSFER 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 http://mindprod.com/jgloss/ftp.html

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
http://mindprod.com/jgloss/rsync.html

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
http://mindprod.com/jgloss/remotefileaccess.html

In any case you are the man the middle copying from source to yourself
then from yourself to target.
 
J

Jeff Schwab

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
work.

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.

http://www.sshtools.com/content/developer/maverick/docs/com/sshtools/scp/ScpClient.html
 
T

Thomas Weidenfeller

Prime said:
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>"

If you want rcp, then just use Runtime.exec() to start rcp.
I want to do this in Java instead of using Shell Scripts for obvious
reasons.

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
Java.

/Thomas
 
P

Prime

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!
 
K

Knute Johnson

Prime said:
Hello,

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:

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.

knute...

email s/nospam/knute/
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top