import java.io.IOException;
import java.io.InputStreamReader;
public class CommandInput {
public static void main(String[] args) {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a command:");
try {
String command = reader.readLine();
Process process = Runtime.getRuntime().exec(command);
BufferedReader processReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while ((line = processReader.readLine()) != null) {
System.out.println(line);
}
process.waitFor();
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}
}
No comments:
Post a Comment