Asterisk AGI with Java

Hello guys!

I have a question to the usage from Java and Asterisk.

How can I get the output of the Asterisk console into my Java program?

What I want is the Output of DumpChan in my Java program to check the used codec. I tried it like this:


public class TestAGI {
public static void main(String[] args) {
	try {
		String inpStream;
		LineNumberReader in = new LineNumberReader(new InputStreamReader(;
			do { 

			} while (inpStream.length() > 0);

//here the important think!!!!!!!///////////////////////////////////////////////
			System.out.println("EXEC DumpChan");
			inpStream = in.readLine();
			System.out.println("EXEC NoOp \"" + inpStream + "\"");		


But the output of NoOp is not the DumpChan stuff, its only “200”. But on the Asterisk console I can see the DumpChan output, so that the EXEC command works!

Do you have any ideas how I can get the DumpChain output with AGI into my code?


ps If you are not able to answer it in Java, you can also use an other language. I just try to understand the STDIn of AGI.

GET FULL VARIABLE on the ${CHANNEL()} function might work.

Hey david55,

this is a good idea. I think it could work to get the stuff I want with Variables! I will try it tomorrow - thanks a lot :smile:

:arrow_right: But in general, has anyone an idea how I can get the console oputput in asterisk into my Java program?