• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Regarding FTP froma remote server

 
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,
I am hereby looking for a remote FTP and i am not able to figure how it can be done.

The scaneraio is : I have 3 servers namely A,B and C.

My program runs on C and it wants to do FTP from A to B on which JAVA is not running.

A,B,C are all Sloaris servers.

So can anyone help me out with Sample code to acheive the same.

Ftp from a to b sitting at C ?? Someone suggested me to use SOCKS proxy but i am not aware of it.

Thanks in advance,
Saurabh
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Machines A and B need to have FTP servers running; Java is not required, and the operating system makes no difference. The client on machine C can be implemented using the Jakarta Commons Net library, which includes an FTP client.

Ftp from a to b sitting at C ??


I don't understand what you are asking here - your program is running on C, but the file should be transferred from A to B? Either ftp the file from A to C, and from there to B, or you can open a shell on A and initiate a direct ftp to B (or vice-versa). The Net library also has rexec/rcmd/rlogin facilities for that.
[ July 29, 2005: Message edited by: Ulf Dittmer ]
 
Saurabh Agrawal
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ulf Dittmer:
Machines A and B need to have FTP servers running; Java is not required, and the operating system makes no difference. The client on machine C can be implemented using the Jakarta Commons Net library, which includes an FTP client.


I don't understand what you are asking here - your program is running on C, but the file should be transferred from A to B? Either ftp the file from A to C, and from there to B, or you can open a shell on A and initiate a direct ftp to B (or vice-versa). The Net library also has rexec/rcmd/rlogin facilities for that.

[ July 29, 2005: Message edited by: Ulf Dittmer ]




Thanks Ulf,
My problem is since servers A & B are 3rd party external servers, so i cant do any changes as far as transfer is concerned. i.e. i cant transfer file from A to C and then from C to B.

So this is not the case.

Now the other option you gave was to open a shell on A and do a direct FTP to B, so the thing is can i open a shell on A from C using JAVA program.

If possible , then can i use Apache common's net library as suggested by you to open a shell on machine A as well.

Please help me out.If you have some sample code then that would be of great help to me.

Awaiting your reply.

Thanks in advance,
Saurabh
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it's strange that they would let you open a shell, but not transfer a file through one of your computer, but OK.

I don't have sample code; I've only used Commons Net for ftp, never for
remote login. I'd suggest reading up on the Unix commands that are mirrored by those facilities, and try it out in your environment.
 
Saurabh Agrawal
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ulf Dittmer:
I think it's strange that they would let you open a shell, but not transfer a file through one of your computer, but OK.

I don't have sample code; I've only used Commons Net for ftp, never for
remote login. I'd suggest reading up on the Unix commands that are mirrored by those facilities, and try it out in your environment.



Tell me can i upload a file from server A , using my JAVA program on server C and uploading the same on server B ? Is it possible through the commons net library?

Saurabh
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tell me can i upload a file from server A , using my JAVA program on server C and uploading the same on server B ? Is it possible through the commons net library?



Commons net implements client-side ftp. With it an app can connect anywhere where there's an ftp server, and upload and download files.
Your wording is not quite clear: you want to upload a file *FROM* C *TO* A, and then upload the same file *FROM* C *TO* B? Or do you want to download *FROM* A to C, and then upload that file *TO* B? But either way, it's possible as long as you have ftp servers on A and B.
 
Saurabh Agrawal
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ulf Dittmer:


Commons net implements client-side ftp. With it an app can connect anywhere where there's an ftp server, and upload and download files.
Your wording is not quite clear: you want to upload a file *FROM* C *TO* A, and then upload the same file *FROM* C *TO* B? Or do you want to download *FROM* A to C, and then upload that file *TO* B? But either way, it's possible as long as you have ftp servers on A and B.



I want to transfer a file from Server A to Server B where FTP services would be running as such but no explicit FTP Servers would be running and my JAVA program would be running on Server C.
So now tell me if i want to transfer a file from A to B where at both ends FTP services which are default of the OS are running, so can i transfer the file from A to B now, using COMMONS NET LIBRARY.

Thanks in advance,
Saurabh
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess what you call "ftp services" I call "ftp server", so let's assume that they're the same thing. I think you can achieve what you're trying to do, but you will need shell access to one of the machines. How that might work with Commons Net, I have no idea, but that is what rexec/rlogin/rcmd do, and Commons Net claims to implement those. The documentation should help you in that regard.
Of course, it might be simpler to write a shell script that does the remote login and ftp, and to just run that using the Runtime and Process classes. Even simpler, use no Java, and run the script from the command line, but maybe it's a requirement to control this from Java.
 
reply
    Bookmark Topic Watch Topic
  • New Topic