Browse Source

TT#72350 move default values to post-getopt

This makes it possible to load values from a config file but also
override them at the CLI.

Change-Id: Ie05c6fccb64d3b9edc8974a24669fb79feca7c0b
(cherry picked from commit dffe3d4b42)
changes/38/36438/1
Richard Fuchs 6 years ago
parent
commit
376441e3ca
1 changed files with 7 additions and 5 deletions
  1. +7
    -5
      utils/rtpengine-ctl

+ 7
- 5
utils/rtpengine-ctl View File

@ -6,9 +6,8 @@ use warnings;
use IO::Socket::INET;
use Getopt::Long;
my $argumentstring = "";
my $ip = "127.0.0.1";
my $port = 9900;
my $ip;
my $port;
my $optret = GetOptions(
'help|h' => sub { showusage(); exit 0; },
@ -16,11 +15,11 @@ my $optret = GetOptions(
'port=i' => \$port,
);
if ($ip =~ s/:(\d+)$//) {
if ($ip && $ip =~ s/:(\d+)$//) {
$port = $1;
}
$argumentstring = "@ARGV";
my $argumentstring = "@ARGV";
$argumentstring = trim($argumentstring);
if (!$argumentstring || !$optret || $port <= 0 || $port > 65535) {
@ -28,6 +27,9 @@ if (!$argumentstring || !$optret || $port <= 0 || $port > 65535) {
exit 1;
}
$ip //= '127.0.0.1';
$port //= 9900;
# create a connecting socket
my $socket = new IO::Socket::INET (
PeerHost => $ip,


Loading…
Cancel
Save