Can get ${SHELL(date)} vaule from agi

hi guys,
i run a java agi ,and want to get a shell valule ,here is my code:

String shell = channel.getFullVariable("${SHELL(date)}");
log.info(“result: [{}]”, shell);

below is agi debug log;
<SIP/8001-000076b3>AGI Rx << GET FULL VARIABLE “${SHELL(date)}”
<SIP/8001-000076b3>AGI Tx >> 200 result=1 (Sun Aug 30 15:04:06 CST 2020
)

but java debug log is:
2020-08-30 15:04:07,211-[AJ DaemonPool-1.2] INFO com.callmanager.agi.Nlp - result: [null]
can you help me,thanks.

ps,shell command runs ok in dialplan. and also can get return value .

As far as I know, the Java class library for AMI is third party maintained, so it is unlikely that you will find expertise on it on this forum.

Are you really using this for date, as you can synthesize this from dialplan functions, or presumably do it natively in Java. I don’t think the Java will be run in a sandbox, here, so you could also access shell commands natively from Java, unless this is EAGI.

actually,i wan to get queue wait time and answer time from queue_log. and the shell command is:
String shell = channel.getFullVariable("${SHELL(grep 1598709776.991795 /var/log/asterisk/queue_log.0 |grep COMPLETECALLER)}");

if there can not way to do it in agi, i will do it natively in Java

It was working at the AGI level for “date”. However, if you look back a week or two, you will see that AGI is not well suited to multi-line responses.

Your problem is either with the class library or how to use it.

you are right…
i change it in the java way:
try {
String cmd = new String { “/bin/sh”, “-c”, “grep " + call.getSessionId()+ " /var/log/asterisk/queue_log |grep COMPLETECALLER” };
Process ps = Runtime.getRuntime().exec(cmd);

            BufferedReader br = new BufferedReader(new InputStreamReader(ps.getInputStream()));
            StringBuffer sb = new StringBuffer();
            String line;
            while ((line = br.readLine()) != null) {
                sb.append(line).append("\n");
            }
            String result [] = sb.toString().split("|");
            call.setBillSec(Long.valueOf(result[0]));
            call.setTotalSec(Long.valueOf(result[5]));
 
            log.info("queuetime is:[{}] [{}] [{}]", call , call.getBillSec(), call.getTotalSec());
 
        } catch (Exception e) {
            log.error("----error-----");
            e.printStackTrace();
        }

the agi level return : (two lines)
<SIP/8001-000076b3>AGI Tx >> 200 result=1 (Sun Aug 30 15:04:06 CST 2020
)

i don’t know why not return: (only one line)
<SIP/8001-000076b3>AGI Tx >> 200 result=1 (Sun Aug 30 15:04:06 CST 2020)

finally,got the answer:

String shell = getFullVariable("${SHELL(echo -n $$(grep 1589265917.223374 /var/log/asterisk/queue_log.0 |grep CONNECT))}");

and the debug output is:

<SIP/8001-00007706>AGI Rx << GET FULL VARIABLE “$${SHELL(echo -n $$(grep 1589265917.223374 /var/log/asterisk/queue_log.0 |grep CONNECT))}”
<SIP/8001-00007706>AGI Tx >> 200 result=1 (1589266005|1589265917.223374|600032|SIP/10235|CONNECT|42|hz-1589265997.223386|8)