Command.java 746 B

123456789101112131415161718192021222324252627282930
  1. package captiveportal;
  2. import java.io.BufferedReader;
  3. import java.io.InputStreamReader;
  4. public class Command {
  5. public boolean Grand (String ip) {
  6. String command = "sudo /bin/bash /portal/rules.sh grand " +ip;
  7. try {
  8. Process process;
  9. process = Runtime.getRuntime().exec(command);
  10. String line;
  11. BufferedReader is = new BufferedReader(new InputStreamReader(process.getInputStream()));
  12. while((line = is.readLine()) != null){
  13. System.out.println(line);
  14. }
  15. if((line = is.readLine()) == "SUCCES") {
  16. return true;
  17. }
  18. else {
  19. return true;
  20. }
  21. } catch ( Exception err ) {
  22. err.printStackTrace();
  23. return false;
  24. }
  25. }
  26. }