Asterisk AGI with Java


#1

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:

import java.io.*;

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

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

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

			System.exit(0);

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?

Thanks!
Luke

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.


#2

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


#3

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?