From 376441e3ca6667e721520fbc358f739ba6294d19 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Mon, 9 Dec 2019 04:24:18 -0500 Subject: [PATCH] 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 dffe3d4b42cbefa648b0451b5056db33a39cdf01) --- utils/rtpengine-ctl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/utils/rtpengine-ctl b/utils/rtpengine-ctl index 9d0f711c5..349b824d6 100755 --- a/utils/rtpengine-ctl +++ b/utils/rtpengine-ctl @@ -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,