~cyrenity/zivios/devel

« back to all changes in this revision

Viewing changes to application/modules/asterisk/scripts/asterisk/bin/getsection

  • Committer: Faraz Khan
  • Date: 2008-09-15 13:29:33 UTC
  • Revision ID: fkhan@zivios.org-20080915132933-d27jml5l29xw4gsr
Initial release to bazaar, code in sync with 0.5.0-release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -w
 
2
#
 
3
# Copyright (c) 2008 Zivios, LLC.
 
4
#
 
5
# This file is part of Zivios.
 
6
#
 
7
# Zivios is free software: you can redistribute it and/or modify
 
8
# it under the terms of the GNU General Public License as published by
 
9
# the Free Software Foundation, either version 3 of the License, or
 
10
# (at your option) any later version.
 
11
#
 
12
# Zivios is distributed in the hope that it will be useful,
 
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
# GNU General Public License for more details.
 
16
#
 
17
# You should have received a copy of the GNU General Public License
 
18
# along with Zivios.  If not, see <http://www.gnu.org/licenses/>.
 
19
#
 
20
# @package              Zivios
 
21
# @copyright    Copyright (c) 2008 Zivios, LLC. (http://www.zivios.org)
 
22
# @license              http://www.zivios.org/legal/license
 
23
# @version              $Id: addattendant 1019 2008-09-08 07:26:34Z gmustafa $
 
24
#
 
25
use lib "/opt/zivios/asterisk/lib";
 
26
use Asterisk::config;
 
27
use Getopt::Long;
 
28
 
 
29
my $filter = 0;
 
30
GetOptions ("name=s" => \$name, "section:s" => \$section, "filter:s" => \$filter);
 
31
 
 
32
my $rc = new Asterisk::config(file=>'/etc/asterisk/'.$name.'.conf',keep_resource_array=>0);
 
33
 
 
34
        $list = $rc->fetch_keys_hashref(section=>$section);
 
35
            while ( my ($key, $value) = each(%$list) ) {
 
36
                        if ($filter eq 'n') {
 
37
                print "$key => ";
 
38
                print "@$value";
 
39
                print "\n";
 
40
                        }
 
41
                        if (($filter ne "") && ($key =~ m/^$filter+/)) {
 
42
                                print "$key => ";
 
43
                                print "@$value";
 
44
                                print "\n";
 
45
                        }
 
46
                }