Jeremy Kister
2016-Apr-13 16:20 UTC
[asterisk-users] recreating extensions.conf from live dialplan ?
On 4/13/16 11:57 AM, A J Stiles wrote:> You could try > *CLI> dialplan showBetween my older backup and dialplan show, I guess that's my best shot. Thanks :D
Steve Edwards
2016-Apr-13 17:26 UTC
[asterisk-users] recreating extensions.conf from live dialplan ?
On Wed, 13 Apr 2016, Jeremy Kister wrote:> Between my older backup and dialplan show, I guess that's my best shot.This should get you close: sudo asterisk -r -x 'dialplan show' >extensions.wip and then feed extensions.wip through: #!/usr/bin/env php <?php // declare variables $tokens = array(); // loop through stdin while ($line = fgets(STDIN)) { // blank line if ("\n" == $line) { printf("\n"); continue; } // remove 'features' $line = str_replace('[features]', '', $line); // remove 'pbx_config' $line = str_replace('[pbx_config]', '', $line); // context if ('[' == substr($line, 0, 1)) { $tokens = explode("'", $line); printf("[%s]\n", $tokens[1]); continue; } // extension if ("'" == substr($line, 2, 1)) { $tokens = explode("'", $line); $line = substr($line, strpos($line, ' ', 20) + 1, 255); printf("\texten = %s,1,\t\t\t%s", $tokens[1], $line); continue; } // label if ('[' == substr($line, 5, 1)) { $line = str_replace(']', '[', $line); $tokens = explode('[', $line); printf("\tsame = n(%s),\t\t\t%s", $tokens[1], $line); continue; } // anything else $line = substr($line, strpos($line, ' ', 20) + 1, 255); printf("\tsame = n,\t\t\t%s", $line); } // (end)?> (I'm not all that hot of a PHP programmer, so if anybody has some constructive criticism, please jump it.) -- Thanks in advance, ------------------------------------------------------------------------- Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST https://www.linkedin.com/in/steve-edwards-4244281
Steve Edwards
2016-Apr-13 17:33 UTC
[asterisk-users] recreating extensions.conf from live dialplan ?
On Wed, 13 Apr 2016, Steve Edwards wrote:> // label > if ('[' == substr($line, 5, 1)) > { > $line = str_replace(']', '[', $line); > $tokens = explode('[', $line); > printf("\tsame = n(%s),\t\t\t%s", $tokens[1], $line); > continue; > }Damn. Missed a line of code. Should be: // label if ('[' == substr($line, 5, 1)) { $line = str_replace(']', '[', $line); $tokens = explode('[', $line); $line = substr($line, strpos($line, ' ', 20) + 1, 255); printf("\tsame = n(%s),\t\t\t%s", $tokens[1], $line); continue; } -- Thanks in advance, ------------------------------------------------------------------------- Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST https://www.linkedin.com/in/steve-edwards-4244281
Jeremy Kister
2016-Apr-14 04:53 UTC
[asterisk-users] recreating extensions.conf from live dialplan ?
On 4/13/2016 1:26 PM, Steve Edwards wrote:> This should get you close: > > sudo asterisk -r -x 'dialplan show' >extensions.wip > > and then feed extensions.wip through:Ya, that's pretty good! besides the fact that I've never used "same" (i understand where it's coming from) and a few contexts confuzzled (missing general/globals and extra parkedcalls - but again I get it) - it seems to be perfect. One for a wiki, somewhere. thanks, -- Jeremy Kister http://jeremy.kister.net/
A J Stiles
2016-Apr-14 09:08 UTC
[asterisk-users] recreating extensions.conf from live dialplan ?
On Wednesday 13 Apr 2016, Jeremy Kister wrote:> On 4/13/16 11:57 AM, A J Stiles wrote: > > You could try > > *CLI> dialplan show > > Between my older backup and dialplan show, I guess that's my best shot. > > Thanks :DI'll have a go this lunchtime at knocking up a Perl script {for that is my language of choice} to try to recreate an extensions.conf file from the `dialplan show` CLI output. All the necessary stuff seems to be there, even labels for GoTo statements ..... -- AJS Note: Originating address only accepts e-mail from list! If replying off- list, change address to asterisk1list at earthshod dot co dot uk .