[Asterisk-Users] Parsing a variable, or rather Splitting a variable
Derek Bruce
dbruce at calgarytelecom.com
Tue Mar 9 17:14:14 MST 2004
Well, after thinking about it some more... try this:
exten => s,1,ChanIsAvail(SIP/2001&IAX2/abc at xyz)
exten => s,2,cut,ToDial=${AVAILCHAN},1
exten => s,3,Dial(${ToDial},20)
----- Original Message -----
From: "Hadar Pedhazur" <hadar at unorthodox.com>
To: <asterisk-users at lists.digium.com>
Sent: Tuesday, March 09, 2004 4:41 PM
Subject: Re: [Asterisk-Users] Parsing a variable, or rather Splitting a
variable
> Derek, this is great, thanks much! I can definitely make this work for
> me, but in practice, my problem is a little more complex, and on the
> off chance that there is a solution, I'll state it. Otherwise, I can
> work around it (I think).
>
> Here's an example of what my input looks like (in reality, it's even
> worse than this, because there are 3 or 4 variable length channels):
>
> ChanIsAvail(SIP/2001&IAX2/abc at xyz)
>
> So, a fixed length substring won't really work for me. Of course,
> worst case scenario here I can test the substring first for whether it
> starts with SIP or IAX2 (for the above), and then branch accordingly.
> That's not too bad (logic-wise), but it adds a number of steps to the
> dialplan that perhaps could be avoided if there was a
> "Split(String,'-',1)" (for example, to pick out the first token)...
>
> Thanks again, since I'm now all set even if my particular needs can't
> be met "directly". :-)
>
> Derek Bruce wrote:
> > given:
> > exten => 2001,1,ChanIsAvail(SIP/2001&SIP/3001)
> > exten => 2001,2,SubString,ToDial=${AVAILCHAN}|0|8
> > exten => 2001,3,Dial(${ToDial},20)
> >
> > you know that your dialstring will be 'SIP/2001', your technology prefix
> > ('SIP/' 4 characters) length plus your extention length (4 characters) =
8
> > characters... a fixed length...
> >
> > for a variable length extention use:
> > exten => _1.,1,ChanIsAvail(SIP/$EXTEN})
> > exten => _1.,2,SubString,ToDial=${AVAILCHAN}|0|${LEN(EXTEN)}+4 )
> > exten => _1.,3,Dial(${ToDial},20)
> >
> > ----- Original Message -----
> > From: "Hadar Pedhazur" <hadar at unorthodox.com>
> > To: <Asterisk-Users at lists.digium.com>
> > Sent: Tuesday, March 09, 2004 3:25 PM
> > Subject: [Asterisk-Users] Parsing a variable, or rather Splitting a
variable
>
> >>The wiki page on ChanIsAvail says:
> >>
> >>"Thus, if you are going to use the value of AVAILCHAN, you need to
> >>strip the session ID off."
> >>
> >>I understand why this is necessary (from seeing what is returned in
> >>the CLI), but I don't see any commands that can accomplish this since
> >>the session id after the "-" is of variable length (so you can't use
> >>":" notation, or StripLSD, etc.).
> >>
> >>I would like to avoid making an external AGI call if possible, and I'm
> >>hoping I'm just missing something obvious here.
> >>
> >>Thanks in advance!
>
> _______________________________________________
> Asterisk-Users mailing list
> Asterisk-Users at lists.digium.com
> http://lists.digium.com/mailman/listinfo/asterisk-users
> To UNSUBSCRIBE or update options visit:
> http://lists.digium.com/mailman/listinfo/asterisk-users
More information about the asterisk-users
mailing list