[Asterisk-Users] ChanIsAvail app setting ${AVAILCHAN} to anunusable value.

Robert Hajime Lanning lanning+asterisk at monsoonwind.com
Tue Oct 7 00:22:33 MST 2003


<quote who="John Todd">
>>On Sunday 05 October 2003 16:41, Robert Hajime Lanning wrote:
>>>  I sent this earlier under "Editting variable contents" but no-one
>>>  has responded.  So, the subject is now more to the problem, instead
>>>  of the solution I was trying to implement.
>>>
>>>  ChanIsAvail returns the channel ID plus "-<session>".
>>>
>>>  How can I edit ${AVAILCHAN} to remove this session ID, so I can use
>>>  its contents in a subsequent Dial statement?
>>
>>Oh, it's quite simple.  You just write your own application to remove
>>the suffix.  Or you wait for someone else to write it.
>>
>>Untested code.  UAYOR.
>>
>>-Tilghman
>
> I don't recall if -<session> is a fixe number of digits.  If so, you
> can use the string manipulation features within Asterisk to cut it
> off.  I don't have the manual reference right here with me, but note
> that you can put negative numbers for ${EXTEN:-1:-3} and the like,
> which will chop things up based on fixed positions within the string.
>
> JT

Not fixed length.  Well it maybe fixed per technology. (Zap vs. SIP...)

I ended up just writing an AGI script.
extensions.conf:
; Now we dial!!!!
exten => 8901,6,AGI(strip-sess,DIALCHANS)
exten => 8901,7,Macro(stdexten,8901,${DIALCHANS})

---------------------------------------------------------------------
#! /usr/bin/perl

$|=1;

$variable = shift;

while ($line = <STDIN>,$line =~ /[^ \n\r]/) { }

print STDOUT "GET VARIABLE $variable\n";
$response = <STDIN>;
$response =~ /^\d+ +result=(\d+) +\((.*)\)\s*$/;
$response = $1;
$data = $2;

if ($response == 1) {
   $data = join("&",map {$_ =~ s/\-\w+$//;$_;} split(/&/,$data));
   print STDOUT "SET VARIABLE $variable \"$data\"\n";
   $response = <STDIN>;
}

exit(0);
---------------------------------------------------------------------

-- 
END OF LINE



More information about the asterisk-users mailing list