Forums Login/signup

Copying file from a server machine to remote machine

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.)
+Pie Number of slices to send: Send
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.

reply
reply
This thread has been viewed 738 times.
Similar Threads
Editing files in a Remote Linux machine using Java
sftp & scp2
Comparint contents of 2 files in different folders
Comparing data in 2 files in different folders
which SFTP server to use on windows 7/XP
More...

All times above are in ranch (not your local) time.
The current ranch time is
Jun 28, 2025 22:42:44.