Last active
March 13, 2016 17:55
-
-
Save santiihoyos/cc13521323d693852833 to your computer and use it in GitHub Desktop.
Creador de script con permisos de ejecución autoañadidos para Linux.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File scriptCreator(String MAC, String interfaz) throws InterruptedException, IOException { | |
File fichero = new File(".tempLixScrip.sh"); | |
BufferedWriter out = null; | |
if (fichero.exists()) { | |
return fichero; | |
} else { | |
out = new BufferedWriter(new FileWriter(".tempLixScrip.sh", true)); | |
out.write("!/bin/bash\n" | |
+ "$USER - sudo with zenity password window\n" | |
+ "zenity --title=\"We need your authorization:\" --text=\"Change MAC requires authorization please enter the Administrator password:\" \\\n" | |
+ "--entry --entry-text \"\" --hide-text \\\n" | |
+ "|sudo -S \"$@\" rfkill block all\n" | |
+ "sleep 1s\n" | |
+ "sudo -S \"$@\" ifconfig " + interfaz + " hw ether " + MAC + " \n" | |
+ "sleep 1s\n" | |
+ "sudo -S \"$@\" rfkill unblock all \n"); | |
Process pro = Runtime.getRuntime().exec("chmod 777 .tempLixScrip.sh"); | |
out.close(); | |
return fichero; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment