asterisk at phreaknet.org
2021-Dec-23 11:11 UTC
[asterisk-users] Exec two commands with ExecIf
> -----Original Message----- > From: asterisk-users <asterisk-users-bounces at lists.digium.com> On Behalf > Of Steve Edwards > Sent: Thursday, December 23, 2021 2:06 AM > To: Asterisk Users Mailing List - Non-Commercial Discussion <asterisk- > users at lists.digium.com> > Subject: Re: [asterisk-users] Exec two commands with ExecIf > > On Thu, 23 Dec 2021, Dovid Bender wrote: > > > Is there any way of using ExecIf to run two commands instead of 1? e.g. > > instead of > > > > Exten 123,1,ExecIf($["FOO" == "BAR"]?BackGround(you-owe)) Exten > > 123,1,ExecIf($["FOO" == "BAR"]?SayNUmber(1000000")) > > > > I would ideally like to do it in one line. > > 1) gotoif() > > 2) gosub() > > 3) AEL > > gosub() is probably 'cleaner' and more maintainable than gotoif(). AEL is good > but sometimes fragile.Sounds like you might benefit from the If/EndIf applications: https://gerrit.asterisk.org/c/asterisk/+/16121 You can specify a condition once, but execute multiple dialplan applications. AEL not needed. No need to branch, especially Gosub which has a huge overhead. This is probably the cleanest way to do it in dialplan, as you don't end up with branching everywhere just to have a conditional execute 2 lines. exten => 123,1,If($["FOO"="BAR"]) same => n,BackGround(you-owe) same => n,SayNumber(1000000) same => n,EndIf() same => n,Playback(goodbye) same => n,Hangup()
Anyone know why this never made it into Asterisk? On Thu, Dec 23, 2021 at 6:12 AM <asterisk at phreaknet.org> wrote:> > -----Original Message----- > > From: asterisk-users <asterisk-users-bounces at lists.digium.com> On Behalf > > Of Steve Edwards > > Sent: Thursday, December 23, 2021 2:06 AM > > To: Asterisk Users Mailing List - Non-Commercial Discussion <asterisk- > > users at lists.digium.com> > > Subject: Re: [asterisk-users] Exec two commands with ExecIf > > > > On Thu, 23 Dec 2021, Dovid Bender wrote: > > > > > Is there any way of using ExecIf to run two commands instead of 1? e.g. > > > instead of > > > > > > Exten 123,1,ExecIf($["FOO" == "BAR"]?BackGround(you-owe)) Exten > > > 123,1,ExecIf($["FOO" == "BAR"]?SayNUmber(1000000")) > > > > > > I would ideally like to do it in one line. > > > > 1) gotoif() > > > > 2) gosub() > > > > 3) AEL > > > > gosub() is probably 'cleaner' and more maintainable than gotoif(). AEL > is good > > but sometimes fragile. > > Sounds like you might benefit from the If/EndIf applications: > https://gerrit.asterisk.org/c/asterisk/+/16121 > You can specify a condition once, but execute multiple dialplan > applications. AEL not needed. > No need to branch, especially Gosub which has a huge overhead. This is > probably the cleanest way to do it in dialplan, as you don't end up with > branching everywhere just to have a conditional execute 2 lines. > > exten => 123,1,If($["FOO"="BAR"]) > same => n,BackGround(you-owe) > same => n,SayNumber(1000000) > same => n,EndIf() > same => n,Playback(goodbye) > same => n,Hangup() > > > -- > _____________________________________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > > Check out the new Asterisk community forum at: > https://community.asterisk.org/ > > New to Asterisk? Start here: > https://wiki.asterisk.org/wiki/display/AST/Getting+Started > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20211223/20d6164d/attachment.html>