[asterisk-users] AGI script

Steve Edwards asterisk.org at sedwards.com
Mon Feb 23 10:48:06 CST 2009


On Mon, 23 Feb 2009, Yawar Hadi wrote:

> so if u want to read extension then supplu variable name like
> $myno=$AGI->get_variable('EXTEN');
> hope u get it

I think passing the variable "on the command line" is more flexible than a 
fixed variable, particularly the much more limiting ${EXTEN}.

My preference is to use the "getopt_long" function to parse the command 
line passed to the AGI. I find

 	exten = _x.,n,agi(dial,--customer-id=112)

to be more "obvious" than

 	exten = _x.,n,agi(dial,${EXTEN})

or

 	exten = 112,n,agi(dial)

This becomes even more obvious when you pass multiple variables:

 	exten = _x.,n,agi(dial\
 		,--announce=winter-specials\
 		,--customer-id=112\
 		,--caller-id=ACME Widgets Inc\
 		,--verbose\
 		,--record\
 		)

(line split for readability)

rather than

 	exten = _x.,n,agi(dial,112,,,winter-specials,ACME Widgets,v,,r)

or

 	exten = 112,n,agi(dial)

Particularly since getopt_long does not care about the order of the 
options.

Thanks in advance,
------------------------------------------------------------------------
Steve Edwards      sedwards at sedwards.com      Voice: +1-760-468-3867 PST
Newline                                             Fax: +1-760-731-3000



More information about the asterisk-users mailing list