Delete files on remote machines AIX/LINUX/SOLARIS/WINDOWS with java.

Hello Everybody,

I want to write a program which will enable me to delete files from remote machines like AIX/LINUX/SOLARIS/WINDOWS. Is there any way I can do this task with java? I can't think of anything. Please suggest me.

Thanks,
Kedlu
kedluAsked:
Who is Participating?
 
CEHJConnect With a Mentor Commented:
How about zebra? You need to be able to access them remotely. Else you need to get an FtpClient that supports deletion

http://sourceforge.net/search/?type_of_search=soft&exact=1&forum_id=0&group_id=0&atid=0&words=java+ftp+client&Search=Search
0
 
CEHJCommented:
That is primarily dependent on the network configuration of both machines. If you have the mechanisms in place you can just create a File and delete it

File f = new File("remotemachine:/a/b/c/d.txt");
boolean deleted = f.delete();
0
 
kedluAuthor Commented:
What do you mean by network configuration? I've AIX machine called "congo"
Linux machine called "zebra". So I just need to give following:

File f = new File("congo:/opt.testdir/test.txt");
boolean deleted = f.delete();

How will it contact remote machine? Doesn't it require username/password? I'm working on Windows 2000.

Thanks,
Kedlu
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
CEHJCommented:
That's 3 OSs you've named. Are we talking about the same LAN?
0
 
sciuriwareCommented:
There is one rule of thumb: if you can SEE a remote file in the local file manager, you can SEE it
with JAVA:    File f = new File("...............");  // Fill in the path.
If you have privileges you can delete the file from the file manager; then you can from JAVA.

;JOOP!
0
 
kedluAuthor Commented:
All the three machines are on company's LAN, I can ping it, I can access it with telnet/ftp.
What is local file manager? I can't map to AIX or LINUX machines. If I have to manage files, i need to telnet to the machine and do file management.

I still did not understand how can I access it.
Thanks,
kedlu
0
 
CEHJCommented:
You said you were on a Windows box. Can you do

dir \\congo\opt.testdir\test.txt

?
0
 
kedluAuthor Commented:
No I can't. I get following erro:

The network path was not found.
0
 
sciuriwareCommented:
If the only way to access those systems is by FTP, then you can use an FTP session
from JAVA to delete files, but it's clumsy.
;JOOP!
0
 
kedluAuthor Commented:
I'm sorry, I was not in the city for few days.
CEHJ and JOOP, I did not understand how can I delete remote files with FTP session.
Can you provide me with sample program?

Thanks
0
 
CEHJCommented:
You tell us which client you're using. You'll probably find there are examples in the download
0
 
kedluAuthor Commented:
I'm using FTP which is installed on windows 2000. I did not install that. I guess it came with Windows 2000.
0
 
CEHJCommented:
I'm talking about a *Java* client
0
 
kedluAuthor Commented:
Oops...ok... java 1.3.1
0
 
CEHJCommented:
So - you need to decide on a Java client. The sdk doesn't really support ftp
0
 
kedluAuthor Commented:
So which java client will support ftp?
0
 
CEHJCommented:
I posted a link earlier
0
 
kedluAuthor Commented:
Let me try one of them. I will be back after trying...thanks!!
0
 
kedluAuthor Commented:
Hello ,

I'm using FTPClient of Jakarta : commons-net-1.2.2.
Following is the sample code. To delete folder, I need to first list them and delete them one by one.
In following program I am just trying to list the files first. I get list of files of the current directory when user logs in and
changedirectory does not work. Can you please suggest me what is going wrong?

import org.apache.commons.net.ftp.*;
import org.apache.oro.text.regex.*;
/public static void main( String [] args) {
      
  try {
      
      FTPClient f= new FTPClient();
      f.connect("completemachinename");
      f.login("username","password");
      System.out.print(f.getReplyString());

      f.changeWorkingDirectory( "//opt//test" );
      FTPFile[] files = f.listFiles();
     
      for ( int i=0;i<files.length;i++)
      {
            System.out.println("You are here");
            System.out.println(files[i]);
      }

      f.disconnect();
} catch(Exception e) {
              
              System.out.println(e);
         }

      }
}

Thanks

0
 
kedluAuthor Commented:
It worked!!
0
 
CEHJCommented:
Good ;-)
0
 
CEHJCommented:
f.changeWorkingDirectory( "//opt//test" );

could almost certainly be

f.changeWorkingDirectory( "/opt/test" );

btw

0
 
kedluAuthor Commented:
Hello,

I'm receiving this error when running this java program from Rational TestManager but from command line it works.

ava.lang.NoClassDefFoundError org/apache/commons/net/SocketClient

I've added jar files in classpath.
Any idea?
Kedlu
0
 
CEHJCommented:
>>I've added jar files in classpath.

Clearly not in Rational TestManager's classpath ;-)
0
 
kedluAuthor Commented:
I had added files to Rational XDE testers classpath. There is no option to add in Rational TestManager's classpath.
But I did one thing, instead of adding in classpath to XDE tester, I imported extracted jar files into XDE tester.
So it is part of datastore now. So TestManager started working. But I did not want to do this, since this changes our architecture...but its ok!!!
Thanks CEHJ...
Kedlu
0
 
CEHJCommented:
8-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.