From 470126f8cebe59d1ae203271443d569d3514f6cb Mon Sep 17 00:00:00 2001 From: Jan Willamowius Date: Tue, 20 Sep 2005 14:59:15 +0000 Subject: [PATCH] Fix args in spong-status (patch by Andrew Ruthven): spong-status's help says that 'status' is the default command. It wasn't, I've made it the default again. The warnings that arguements were missing were being lost when the help was printed. Changed them from warnings to prints. The tabbing in the help output was slightly out, cleaned it up. --- src/spong-status.pl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/spong-status.pl b/src/spong-status.pl index 402e92e..2ad71b6 100755 --- a/src/spong-status.pl +++ b/src/spong-status.pl @@ -3,7 +3,7 @@ # This program can be used to send Status update messages to the Spong Server # from shell scripts or other external programs. # -# $Id: spong-status.pl,v 1.10 2003/02/26 15:07:33 sljohnson Exp $ +# $Id: spong-status.pl,v 1.11 2005/09/20 14:59:15 willamowius Exp $ use POSIX; use Getopt::Long; @@ -34,7 +34,6 @@ if( ! GetOptions( \%opt, @options ) ) { warn "Incorrect usage:\n\n"; &help(); } &help if defined $opt{'help'}; -#$opt{'cmd'} = 'status' if ! defined $opt{'cmd'}; #if ( $opt{'cmd'} !~ /^(status)$/) { warn "Invalid --cmd\n\n;" &help(); } #if ( ! defined $opt{'host'} ) { warn "--host is required\n\n"; &help(); } #if ( ! defined $opt{'service'} ) { warn "--service is required\n\n"; &help(); } @@ -44,22 +43,23 @@ if( ! GetOptions( \%opt, @options ) ) { warn "Incorrect usage:\n\n"; &help(); } my($cmd, $host, $service, $color, $summary, $ttl) = @ARGV; +$opt{'cmd'} = 'status' if ! defined $opt{'cmd'}; if (! $cmd && defined $opt{'cmd'}) { $cmd = $opt{'cmd'}; } -if ( $cmd !~ m/status|event|page/ ) { warn "Invalid cmd\n\n"; &help(); } +if ( $cmd !~ m/status|event|page/ ) { print "Invalid cmd\n\n"; &help(); } if ( ! $host && defined $opt{'host'} ) { $host = $opt{'host'}; } -if ( ! $host ) { warn "Host is required\n\n"; &help(); } +if ( ! $host ) { print "Host is required\n\n"; &help(); } if ( ! $service && defined $opt{'service'} ) { $service = $opt{'service'}; } -if ( ! $service ) { warn "Service name is required\n\n"; &help(); } +if ( ! $service ) { print "Service name is required\n\n"; &help(); } if ( ! $color && defined $opt{'color'} ) { $color = $opt{'color'}; } if ( $color !~ /red|yellow|green/ ) { - warn "Invalid status color. Must be green, yellow, or red.\n\n"; + print "Invalid status color. Must be green, yellow, or red.\n\n"; } if ( ! $summary && defined $opt{'summary'} ) { $summary = $opt{'summary'}; } -if ( ! $summary ) { warn "Summary text is required\n\n"; &help(); } +if ( ! $summary ) { print "Summary text is required\n\n"; &help(); } if ( ! defined $opt{'message'} && ! defined $opt{'file'} ) { - warn "--message or --file is required\n\n"; &help(); } + print "--message or --file is required\n\n"; &help(); } if ( defined $opt{'message'} && defined $opt{'file'} ) { - warn "Only one of --message or --file can be specified\n\n"; &help(); } + print "Only one of --message or --file can be specified\n\n"; &help(); } $ttl = defined $opt{'ttl'} ? $opt{'ttl'} : 0; @@ -103,7 +103,7 @@ Usage: spong-status [--help] Where "options" are: - --help Print this help text. + --help Print this help text. --cmd status Command type being sent to Spong Server. Defaults to 'status'. --host name Name of the host being reported. -- 2.30.2