kedlu
asked on
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
I want to write a program which will enable me to delete files from remote machines like AIX/LINUX/SOLARIS/WINDOWS.
Thanks,
Kedlu
ASKER
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/t est.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
Linux machine called "zebra". So I just need to give following:
File f = new File("congo:/opt.testdir/t
boolean deleted = f.delete();
How will it contact remote machine? Doesn't it require username/password? I'm working on Windows 2000.
Thanks,
Kedlu
That's 3 OSs you've named. Are we talking about the same LAN?
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!
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!
ASKER
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
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
You said you were on a Windows box. Can you do
dir \\congo\opt.testdir\test.t xt
?
dir \\congo\opt.testdir\test.t
?
ASKER
No I can't. I get following erro:
The network path was not found.
The network path was not found.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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!
from JAVA to delete files, but it's clumsy.
;JOOP!
ASKER
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
CEHJ and JOOP, I did not understand how can I delete remote files with FTP session.
Can you provide me with sample program?
Thanks
You tell us which client you're using. You'll probably find there are examples in the download
ASKER
I'm using FTP which is installed on windows 2000. I did not install that. I guess it came with Windows 2000.
I'm talking about a *Java* client
ASKER
Oops...ok... java 1.3.1
So - you need to decide on a Java client. The sdk doesn't really support ftp
ASKER
So which java client will support ftp?
I posted a link earlier
ASKER
Let me try one of them. I will be back after trying...thanks!!
ASKER
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("completemachine name");
f.login("username","passwo rd");
System.out.print(f.getRepl yString()) ;
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
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("completemachine
f.login("username","passwo
System.out.print(f.getRepl
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
ASKER
It worked!!
Good ;-)
f.changeWorkingDirectory( "//opt//test" );
could almost certainly be
f.changeWorkingDirectory( "/opt/test" );
btw
could almost certainly be
f.changeWorkingDirectory( "/opt/test" );
btw
ASKER
Hello,
I'm receiving this error when running this java program from Rational TestManager but from command line it works.
ava.lang.NoClassDefFoundEr ror org/apache/commons/net/Soc ketClient
I've added jar files in classpath.
Any idea?
Kedlu
I'm receiving this error when running this java program from Rational TestManager but from command line it works.
ava.lang.NoClassDefFoundEr
I've added jar files in classpath.
Any idea?
Kedlu
>>I've added jar files in classpath.
Clearly not in Rational TestManager's classpath ;-)
Clearly not in Rational TestManager's classpath ;-)
ASKER
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
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
8-)
File f = new File("remotemachine:/a/b/c
boolean deleted = f.delete();