This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Copying file from a server machine to remote machine

 
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: 42970
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: 18423
60
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.
 
He's my best friend. Not yours. Mine. You can have this tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!