I want to get total free E1 channels on media server in my java program. I used following code to get my desired result:
String command = "asterisk -rx " + '"' + "ss7 linestat " + '"' + " |grep " + '"' + "Idle" + '"' + " |wc -l";
Process p = Runtime.getRuntime().exec(command);
p.waitFor();
BufferedReader buf = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = "";
while ((line = buf.readLine()) != null)
{
freeE1s += line + "\n";
}
System.out.println(freeE1s);
When I execute above command in linux shell using kitty then it works fine and return count but when i use this jar then i get exception. I debugged code by logging and found buf.readLine() returns null.
Edit 1:
Don't worry about exception it's only parsing output to integer which caused exception actually the problematic thing is when I logged buf.readlin() it returned null which of course cannot be parsed to int.