Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Copying file from a server machine to remote machine  RSS feed

 
umesh rama
Greenhorn
Posts: 5
Hibernate Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am developing a web application in java(JSF 2.0 - Prime Faces). I need to do below operation. My appllication is running on WLS server. WLS is deployed on a server(say Machine-X). In my application i have a requirement , where i have to copy file from Machine-X to another Machine-Y. The Machine-Y is access restricted. When i tried to copy the file from my app, getting no access exception. I have full control over Machine-Y. We cannot use SFTP as SFTP cannot be installed on target machine(Machine-Y). Robocopy is failing for some use cases. Is there any other way we can copy/write file from one server to other by providing userid/password in java
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What kind of access do you have to that machine? Shared directory or FTP are two options, but many others are possible since you have full control over the machine. Or maybe you don't, since you can't install SFTP? (I don't recommend you do that, by the way.)
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Umesh!

There are several ways to securely get a file from one machine to another, most of which aren't related to Java or J2EE.

I haven't used SFTP in ages. Most commonly I use rsync or scp (filecopy via ssh). You can make this a trivial process by creating a "copy-only" account on the destination (target) machine, generating SSL certs and handing one to the source machine, eliminating the need for a password.

You can also make this happen via J2EE by persuading the target machine to "pull" a copy of the file through a source machine webapp using a program such as wget or curl on the target machine. The main issue there (assuming you're allowed to install the client) is that something has to tell the target machine to pull the file. That can be done via a manual operator intervention or a scheduled (cron) job.

Additional options may exist, depending on what OS's the source and destination machines are running.

You almost certainly will have to ensure some sort of program and security credentials are installed on the target machine, since otherwise the target machine would be insecure to begin with and you'd be making an exercise in futility. To minimize risk, it's best to inventory what applications are already installed, and of those apps, which ones the system operators are most comfortable with.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!