Hello,
I have a servlet which is supposed to execute a shell command and display the output. The shell command is as follows and this is the output at the command line:
localhost:~#serctl ul show 2045
<sip:
[email protected]>;q=1;expires=456778
However my servlet code which I have included below, only prints ";q=1;expires=456778". It leave out the line in the "<>". I suspect this is something to do with the tags. Can someone tell me how to fix this?
String[] command = { "serctl", "ul", "show", "2045" }; // Only change!
Runtime runtime = Runtime.getRuntime();
Process process = null;
try {
process = runtime.exec(command);
BufferedReader in =
new BufferedReader(new InputStreamReader(process.getInputStream()));
// Read and print the output
String line = null;
while ((line = in.readLine()) != null) {
out.println(line);
}
}
catch (Exception e) {
out.println("Problem with command");
}
Many thanks in advance for the help,
Aisling.