1

I've recently started an internship and I'm having some issues with Java in the enterprise environment. I've been assigned the task of porting the functionality of an old windows shell script to java so it may be ran on one of our JVMs.

The shell script runs on one of the Windows servers and grabs the previous days log files from a couple of linux boxes then FTPs them to another Windows machine.

I'm not quite sure how to achieve this functionality using java. I only can SSH into the linux boxes. I have got the connection working for the Windows file share, just not sure of the best way to connect to the linux boxes.

I've considered using one of the SSH libraries, but would prefer to avoid using a third party library.

Any insight would be great. Thanks!

steve
  • 11
  • 1
  • Why does it have to use ftp or are you referring to SMB? – Ishmael Jun 22 '10 at 13:34
  • It does not have to use FTP, in fact my implementation will not be able to. After playing around I've decided to use Ganymed's SSH library. It has great documentation and examples. I tried JSCH but found the lack of both documentation and examples scary for a new comer. Thanks again! – steve Jun 22 '10 at 14:33

3 Answers3

2

Java development is all about the appropriate use of third-party libraries. You can try and avoid it, but you won't get anywhere.

I suggest using JSch for your SSH/SCP/SFTP needs.

skaffman
  • 398,947
  • 96
  • 818
  • 769
2

You're looking for SFTP. Look at How to retrieve a file from a server via SFTP?.

Community
  • 1
  • 1
Dave
  • 5,133
  • 21
  • 27
-1

Try using SCP (an FTP-style way to transfer files, but it uses SSH) to transfer the files from Linux.

Rich
  • 15,602
  • 15
  • 79
  • 126
  • Oops, I wasn't very clear - I meant using the protocol SCP from within a Java app using a library, not using Runtime.exec() to kick off pscp. – Rich Jun 22 '10 at 13:57