I have a Java application (web) that creates a text file. I need to copy that text file to a remote Unix server. Can anyone tell me if I am on the right track with the following code? I'm not sure if my Unix syntax is right.
//Password is "test" //Local directory is "C:\\Tomcat 5.5\\webapps\\MyProject\\input.txt //Remote directory is "test.web.mycompany.com:/data/testRuntime rt"
a good solution depends much on your requirements. What about transfer speed? Security? The network topology (subnets, routers, firewalls etc.)?
Your idea is surely a good starting point. Generally running the UNIX service for "rcp" should be regarded as unsafe because the password is transfered in plain text and anybody could sniff it to manipulate or destroy the data. As I said it depends on your requirements if this is really an issue but you should at least be aware of this as potential security problem.
Besides your planned solution there are many alternative scenarios which also have their strengths and weaknesses. Some other ideas which come quickly to mind are RMI, FTP transfer without special Java code, a shared NFS or SMB network filesystem, a pure Java socket connection without the "rcp" service and many more.
I'd suggest to try your own solution and think about alternatives if you have problems or you aren't really lucky with it.