Cómo llamar y ejecutar scripts de shell en código Java
//Uso: Runtime.getRuntime().exec("command");
String?shpath="/test/test.sh";//Ruta del programa
Proceso ?proceso?=null;
String?command1?=?"chmod?777?"?+?shpath;
intenta?{? Runtime.getRuntime().exec( comando1 ?).waitFor();?
}?catch?{?
e1.printStackTrace();?
}catch?{ e.printStackTrace ( );?
}
Cadena?/parámetros
Cadena?command2?=?"/bin/sh?"?+?shpath?+? ?"?+?var;?
Runtime.getRuntime().exec(command2).waitFor();