0

I have a java web application deployed on Tomcat in my Linux server. When running the application i need a bunch of text files (from that server) to be copied automatically to a destination which is a Windows based machine . Are there any libraries available for that?

Ayush
  • 485
  • 2
  • 6
  • 19

4 Answers4

1

I know of no specific libraries, but this looks like it can be solved by using some NAS or SMB-based shared directory solution. Does it suit you?

Jorge_B
  • 9,712
  • 2
  • 17
  • 22
  • I looked through the SMB shared option, not much feasible for me as the destination is much dynamic. I looked through JSCH, are there any possibilites of using that? – Ayush Jan 27 '14 at 11:19
  • It depends on how dynamic is your destination. Do you have some application listening to an SSH channel in the destination machine? Is that application able to read from some temporary fixed location (be it an SMB-shared directory, or a CLOB in a database, or whatever) and then write it where it needs? – Jorge_B Jan 27 '14 at 11:22
  • An FTP server in your destination machine would be much simpler as The Thom suggests, if you know where to leave your data – Jorge_B Jan 27 '14 at 11:23
  • No, i cant have any additional application on that destination. All I have is access credentials. – Ayush Jan 27 '14 at 11:24
  • Then your application must be informed in some way beforehand of where to leave the files (be it by FTP, SMB directory, etc.) or you won't be able to transfer your files... I am sorry that I can be of no more help :( – Jorge_B Jan 27 '14 at 11:29
  • Okay, I think i will ask atleast a SSH listner to be made available for connection. – Ayush Jan 27 '14 at 11:45
1

FTP would be the classic solution. Is this over a public or private network? If public, you would probably want to look at one of many secure FTP solutions available.

Thom
  • 14,013
  • 25
  • 105
  • 185
  • FTP is not a good solution for obvious security reasons. – KarlP Jan 27 '14 at 12:26
  • @KarlP As I indicated, if going over a public network, the user should find a secure FTP library, of which there are several I've seen. – Thom Jan 27 '14 at 12:27
1

Assuming the folder on the Windows server that you want to copy to is setup for sharing, and you have the credentials, and there are no other services are running on the Windows machine that can be used for file copying (such as ftp, ssh, http, https, etc.) - probably the best way to do what you want would be to setup a samba client (smbclient) on the Linux machine that mounts the shared folder on the Windows server that you want to copy to.

mti2935
  • 11,465
  • 3
  • 29
  • 33
0

The ubiquitous secure shell protocol SSH include SCP - "Secure Copy" -which perhaps not surprisingly can be used to copy files. (There is also SFTP, but it's better suited for user interaction.)

SSH and SCP is a better solution than FTP.

SSH library for Java

There are several ssh servers available for windows: I know of two :PowerShell Server or cygwin sshd.

Cygwin is open source and free and sshd is based on openssh. (I think.)

Community
  • 1
  • 1
KarlP
  • 5,149
  • 2
  • 28
  • 41