executer pls commande - Java - Programmation
Marsh Posté le 23-04-2014 à 01:49:40
Bonsoir je souhaiterai s'avoir comment exécuter plusieurs commandes linux et afffiche le resulat de la comande 6 dans jtextarea . j'ai testé ce code mais il ne marche pas Process P; // String command = "nmap -sS -Pn -A -oX Test.xml " +addrip.getText(); // String command1= "/etc/init.d/postgresql start"; //String command2= "service metasploit start"; String command3= "msfconsole "; //String command4= "db_status"; //String command5= "db_import Test.xml"; //String command6= "db_service"; Process p = null; try { p = Runtime.getRuntime().exec(command3); BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); String line; while ((line = reader.readLine())!= null) { // jTextArea1.setText(line); System.out.println(line); } } catch (IOException e) { e.printStackTrace(); } }
Make sure you enter the(*)required information where indicate.HTML code is not allowed
Marsh Posté le 23-04-2014 à 01:49:40
Bonsoir
je souhaiterai s'avoir comment exécuter plusieurs commandes linux et afffiche le resulat de la comande 6 dans jtextarea . j'ai testé ce code mais il ne marche pas
Process P;
// String command = "nmap -sS -Pn -A -oX Test.xml " +addrip.getText();
// String command1= "/etc/init.d/postgresql start";
//String command2= "service metasploit start";
String command3= "msfconsole ";
//String command4= "db_status";
//String command5= "db_import Test.xml";
//String command6= "db_service";
Process p = null;
try {
p = Runtime.getRuntime().exec(command3);
BufferedReader reader =
new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while ((line = reader.readLine())!= null) {
// jTextArea1.setText(line);
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
}
}