Ai
1 Star 0 Fork 0

zip/rtpengine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
rtpengine-get-table 1.10 KB
一键复制 编辑 原始数据 按行查看 历史
Guillem Jover 提交于 2021-09-13 20:10 +08:00 . TT#137760 Fix table handling
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
use Config::Tiny;
sub showusage {
print <<HELP;
Usage: rtpengine-get-table <option>...
Options:
-h, --help print this help message.
--config-file=<pathname> use <pathname> as the config file.
--config-section=<name> use <section> instead of 'rtpengine'.
--fallback-table=<index> use <index> as fallback table instead of 0.
HELP
}
my %options = (
'help' => sub { showusage(); exit 0 },
'config-file' => '/etc/rtpengine/rtpengine.conf',
'config-section' => 'rtpengine',
'fallback-table' => -1,
);
Getopt::Long::Configure('require_order');
my $optret = GetOptions(\%options,
'help|h',
'config-file=s',
'config-section=s',
'fallback-table=i',
);
if (!$optret) {
showusage();
exit 1;
}
my $cfg = Config::Tiny->read($options{'config-file'});
if (not defined $cfg) {
die "error: " . Config::Tiny->errstr . "\n";
}
my $cfg_section = $options{'config-section'};
my $table = $cfg->{$cfg_section}{table} // $options{'fallback-table'};
print "$table\n";
1;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zip/rtpengine.git
git@gitee.com:zip/rtpengine.git
zip
rtpengine
rtpengine
master

搜索帮助