Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. import java.io.File;
  2.  
  3. public class FindProject {
  4. public static void findProgram(String ip) {
  5. try
  6. {
  7.  
  8. // create a new process
  9. System.out.println("Creating Process");
  10.  
  11. //ProcessBuilder builder = new ProcessBuilder("nmap", "-A", ip);
  12. ProcessBuilder builder = new ProcessBuilder("bash", "/tmp/script_test.sh", ip);
  13. //builder.command("cat", "NajdeneZariadenia.txt");
  14. //builder.command("sed", "'1d;", "2d;", "$d'", "NajdeneZariadenia.txt", ">", "NajdeneZariadenia.txt");
  15. File fileName = new File(String.format("/tmp/text.txt"));
  16. builder.redirectOutput(fileName);
  17.  
  18. Process pro = builder.start();
  19.  
  20. while (pro.isAlive()){
  21. Thread.sleep(100);
  22. }
  23.  
  24. // kill the process
  25. pro.destroy();
  26. System.out.println("Process destroyed");
  27.  
  28. }
  29. catch (Exception ex)
  30. {
  31. ex.printStackTrace();
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement