import java.io.*;
class LinuxInteractor {
static public void main
(String[] args
) { String[] cmdArr
= {"ls",
"-l"}; LinuxInteractor.executeCommand(cmdArr);
}
static public void executeCommand
(String[] commandArr
) { System.
out.
println("Linux command: " + java.
util.
Arrays.
toString(commandArr
));
try {
ProcessBuilder pb = new ProcessBuilder(commandArr);
pb.redirectErrorStream(true);
proc.getInputStream()));
System.
out.
println("Process started !");
while ((line = in.readLine()) != null) {
}
proc.destroy();
System.
out.
println("Process ended !"); x.printStackTrace();
}
}
}
aW1wb3J0IGphdmEuaW8uKjsKCmNsYXNzIExpbnV4SW50ZXJhY3RvciB7CgogICAgc3RhdGljIHB1YmxpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgICAgIFN0cmluZ1tdIGNtZEFyciA9IHsibHMiLCAiLWwifTsKICAgICAgICBMaW51eEludGVyYWN0b3IuZXhlY3V0ZUNvbW1hbmQoY21kQXJyKTsKICAgIH0KICAgIAogICAgc3RhdGljIHB1YmxpYyB2b2lkIGV4ZWN1dGVDb21tYW5kKFN0cmluZ1tdIGNvbW1hbmRBcnIpIHsKICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIkxpbnV4IGNvbW1hbmQ6ICIgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICsgamF2YS51dGlsLkFycmF5cy50b1N0cmluZyhjb21tYW5kQXJyKSk7CgogICAgICAgIHRyeSB7CiAgICAgICAgICAgIFByb2Nlc3NCdWlsZGVyIHBiID0gbmV3IFByb2Nlc3NCdWlsZGVyKGNvbW1hbmRBcnIpOwogICAgICAgICAgICBwYi5yZWRpcmVjdEVycm9yU3RyZWFtKHRydWUpOwogICAgICAgICAgICBQcm9jZXNzIHByb2MgPSBwYi5zdGFydCgpOwogICAgICAgICAgICBCdWZmZXJlZFJlYWRlciBpbiA9IG5ldyBCdWZmZXJlZFJlYWRlcihuZXcgSW5wdXRTdHJlYW1SZWFkZXIoCiAgICAgICAgICAgICAgICAgICAgcHJvYy5nZXRJbnB1dFN0cmVhbSgpKSk7ICAgICAgICAgICAgIAogICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIlByb2Nlc3Mgc3RhcnRlZCAhIik7CiAgICAgICAgICAgICAKICAgICAgICAgICAgU3RyaW5nIGxpbmU7ICAgICAgICAgICAgIAogICAgICAgICAgICB3aGlsZSAoKGxpbmUgPSBpbi5yZWFkTGluZSgpKSAhPSBudWxsKSB7CiAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4obGluZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgIAogICAgICAgICAgICBwcm9jLmRlc3Ryb3koKTsKICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJQcm9jZXNzIGVuZGVkICEiKTsKICAgICAgICB9IGNhdGNoIChFeGNlcHRpb24geCkgewogICAgICAgICAgICB4LnByaW50U3RhY2tUcmFjZSgpOwogICAgICAgIH0KICAgIH0gICAgCn0=