Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- public class FindProject {
- public static void findProgram(String ip) {
- try
- {
- // create a new process
- System.out.println("Creating Process");
- //ProcessBuilder builder = new ProcessBuilder("nmap", "-A", ip);
- ProcessBuilder builder = new ProcessBuilder("bash", "/tmp/script_test.sh", ip);
- //builder.command("cat", "NajdeneZariadenia.txt");
- //builder.command("sed", "'1d;", "2d;", "$d'", "NajdeneZariadenia.txt", ">", "NajdeneZariadenia.txt");
- File fileName = new File(String.format("/tmp/text.txt"));
- builder.redirectOutput(fileName);
- Process pro = builder.start();
- while (pro.isAlive()){
- Thread.sleep(100);
- }
- // kill the process
- pro.destroy();
- System.out.println("Process destroyed");
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement