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       sedwa...@sedwards.com      Voice: +1-760-468-3867 PST
            https://www.linkedin.com/in/steve-edwards-4244281

--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
              http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users

Reply via email to