wood burning stoves 2.0*
The moose likes Linux / UNIX and the fly likes Try to execute UNIX shred with processbuilder Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Try to execute UNIX shred with processbuilder" Watch "Try to execute UNIX shred with processbuilder" New topic
Author

Try to execute UNIX shred with processbuilder

Fuat Cetino
Greenhorn

Joined: Jan 13, 2010
Posts: 2
Dear forum user,

I try to build a program that execute shred with java process builder under SLES10.
Could anyone tell me, why the following code sample does not work? I get every time "no success"

ProcessBuilder builder = null;
builder = new ProcessBuilder("shred", "/opt/temp/testfile.txt");

builder.directory(new File(sfd.filePath));
try {
Process proc = builder.start();
proc.waitFor();
if (proc.exitValue() == 0)
/*DEUB*/System.out.println("success");
else
/*DEUB*/System.out.println("no success");

} catch (IOException e) {

e.printStackTrace();
} catch (InterruptedException e) {

e.printStackTrace();
}


Thank you for help.

Best regards,
Ali
Fuat Cetino
Greenhorn

Joined: Jan 13, 2010
Posts: 2
Ok, I solved the problem. The path to my file in builder.directory (see below) was wrong:

Correct: builder.directory(new File("/opt/temp"));

Wrong: builder.directory(new File("/opt/tmp"));

Best regards,
Ali
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Try to execute UNIX shred with processbuilder
 
Similar Threads
Catching InputStream from Runtime/Process
Problem with Process and his OutputStream
Checkout from CVS using Maven
Unable to parse xml file with # in the filename
Opening an external program