• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Copy file from Windows to remote Unix Server

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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"

String cmd = "rcp -pw password C:\\Tomcat 5.5\\webapps\\MyProject\\input.txt test.web.mycompany.com:/data/test

Runtime rt = Runtime.getRuntime();
Process p= rt.exec(cmd);

BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));

BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));

Help is appreciated!
 
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Megan,

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.

Marco
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic