Interacting with external Apps - How to use the output


I´m trying to execute and external application from the dialplan but I cannot use the output from it in the dialplan.
To send messages to my pager company I use http get.
In the dialplan I created an extension to send messages to pagers and receive the return code ( OK “sent” or NOK “not sent” )
I´m using http get method with "elinks"
This is the extension in the dial plan:

exten => 6969,1,Answer
exten => 6969,2,DigitTimeout(4)
exten => 6969,3,ResponseTimeout(5)
exten => 6969,4,Read(PIN,askpin,11) ;Enter the pin followed by #
exten => 6969,5,System(elinks -dump“EnvMsg?Pager=”${PIN}"&Message=test")
exten => 6969,6,Gotoif($["${ENV(ASTERISK_PROMPT)}" = “OK”]?8:10)
exten => 6969,7,Playback(sent)
exten => 6969,8,goto(10)
exten => 6969,9,Playback(notsent)
exten => 6969,10,PlayBack(vm-goodbye)
exten => 6969,11,HangUp()

I´m trying to read the return code from the asterisk cli prompt, but it´s not working.

I will appreciate if someone could help me in this matter.
Many thanks,


Use Agi instead of system. Example below, not tested, should point you in the right direction.

exten => 6969,5,Agi(sendpage.agi|${PIN})
exten => 6969,6,Gotoif($["${sent}" = “OK”]?8:10)


sent=/usr/bin/elinks -dump … ssage=test
echo “SET VARIABLE sent $sent “”\n”