Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Find a Folder in Remote Machine

 
Devipriya Swaminathan
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Friends,
How can we search and find a folder(or)a directory in a Remote Machine?
Any Help.
Thanks.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That depends on what kind of access you have to that machine - Telnet/SSH, FTP, HTTP, WebDAV, SMB, ... ?
 
Devipriya Swaminathan
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ulf,
Thanks for your reply .
But my requirement is , i have to find a folder in remote machine using RMI or Networking concept , i mean through java coding.

Thanks&Regards.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RMI can't be used directly to access the file system (unless you want to program a file search API, and make that availabel remotely, for which you'd need to install software on the remote machine).

All protocols I mentioned are available in Java, but they differ widely in how they can be used for searching for a file. That's why I asked which ones are available to you.
 
Devipriya Swaminathan
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ulf,
Once again many thanks.
And i am sorry for not getting you properly in your last reply.
I am new to RMI and networking,thats why i was unable to understand your question .
Anyway , it will be either HTTP or FTP access to that machine.
But i dont have any idea of how to accomplish this .
can you please guide me ?
Thanks in advance.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FTP and HTTP clients are available for Java. Both protocols obviously limit you to the directories that the respective server makes available.

With FTP, you can recursively work your way through all directories, and look for the file you seek.

HTTP is rather limited for searching. You'd have to access pages and hope that you find links in them that point to files, possibly following them recursively. Or maybe the server returns a directory listing when accessing a URL ending in "/". But either way, you'd have to parse the result and interpret it. Not good. A tool like HttpUnit makes dealing with the resulting HTML easier, giving you a DOM view into it.
 
Devipriya Swaminathan
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
I have been searching google to find out any sample code which uses HTTP or FTP protocols.Can u please provide me with sample code for how to start?
Thanks & Regards
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's your assignment, you have to do some research on your own.

If you're familiar with FTP, then the API is pretty straightforward. There are also test cases that demonstrate some of the functionality. You just need to add recursion through all directories until you find the file you're looking for.
[ June 01, 2006: Message edited by: Ulf Dittmer ]
 
Devipriya Swaminathan
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
I have already finished the recursion logic and all for finding the folder and subfolders information (for the local machine).
Even i have got some idea of how to do it with FTP.It seems rather simple.
I just want to know whether it is possible to find a directory in the remote machine to which i have Http access.
Can u please clarify me in this regard?
Thanks & Regards
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not really. If you know its name and path, you can check whether it exists in the web hierarchy, but that is not searching as I would define it.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just want to know whether it is possible to find a directory in the remote machine to which i have Http access.
Can u please clarify me in this regard?

Short answer: NO
Longer answer: There has to be some cooperating process on the remote machine that your application can talk to.
Evenlonger answer: Possible processes on the remote machine include an FTP server etc as mentioned by Ulf.

If you have zero control over processes on the remote machine, you cant have access to the file system - basic security. Thats why virus writers have to entice you to run some sort of code to get control of your file system.

Bill
 
Devipriya Swaminathan
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much for all your interest and replies.
I have one more doubt , like can we access an another machine which is connected through Local area network and find out a particular folder?
If so how? Do i need to use RMI ?
Thanks&Regards.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It matters little whether the machine is on a LAN across the room, or around the world. The question is the same: what kind of access to it do you have?
 
Devipriya Swaminathan
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf,
Thank you so much for your interest and patience.
The machine is on a LAN across the room. Through networking it gives me the machine name if i give ip address and vice versa. But how to establish a connection between the machines to access that? I have no control over (like http or ftp)other machines.

Thanks&Regards.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Re-read and consider my last post: There are any number of ways to access a machine, regardless of its location. Which ones are available to you is impossible for us to say, because we have no knowledge of your network and the machines connected to it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic