• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Try to execute UNIX shred with processbuilder

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Every time you till, you lose 30% of your organic matter. But this tiny ad is durable:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic