Does not work* with global variables. Does not work with some variables that are generated by modules.
(* now works for global variables in 1.2.10 - see http://bugs.digium.com/view.php?id=7609 )
'Variable' actually includes functions (but no expression parsing). Tested on 1.2.13.
EXAMPLE:
QUESTION:
GET VARIABLE UNIQUEID
ANSWER:
200 result=1 (1187188485.0)
Returns:
failure or not set: 200 result=0
success: 200 result=1 <value>
PHP example
function __read__() {
global $in, $debug;
$input = str_replace("\n", "", fgets($in, 4096));
if ($debug) echo "VERBOSE \"read: $input\"\n";
return $input;
}
function __write__($line) {
global $debug;
if ($debug) echo "VERBOSE \"write: $line\"\n";
print $line."\n";
}
//get the variable and strip of all the extra stuff around it
__write__("GET VARIABLE MYDIALPLANVAR");
$res = substr(strrchr(__read__(),"("),1,-1);
__write__("EXEC NOOP '======??? MYDIALPLANVAR: ".$res." ???======'\n");
__read__();
Tip
In many earlier versions of Asterisk (typically 1.0.x) the GET VARIABLE command doesn't appear to work at all. You can, however, pass your variables to the script when calling it from the dialplan through AGI(), example:exten => 1234,1,AGI(test.agi,${CALLERIDNUM})
and then in PHP, for example, use this with the help of $argv[1].
See also
Go back to Asterisk AGI
Page Changes
global variables