Skip to content
Snippets Groups Projects
Commit 30dde1e4 authored by Tomáš Plesník's avatar Tomáš Plesník
Browse files

pridan vypis verze skriptu, uprava napovedy

parent 1d37b647
No related branches found
No related tags found
No related merge requests found
......@@ -32,23 +32,42 @@ WardenCommon::loadConf($conf_file);
# FUNCTIONS
################################################################################
sub usage {
print "Usage: $RealScript [without parameters]\n";
print "Usage: $RealScript (without parameters) [-h -V]\n";
exit 1;
}
sub help {
print "$RealScript (without parameters) [-h -V]\n";
print "-h print this text and exit\n";
print "-V print version and exit\n";
exit 0;
}
sub version {
print "$RealScript: Version: $VERSION\n";
exit 0;
}
################################################################################
# MAIN
################################################################################
our ($opt_h);
our ($opt_h, $opt_V);
die usage unless getopts("h");
my $help = $opt_h;
die usage unless getopts("hV");
my $help = $opt_h;
my $script_version = $opt_V;
# catch help param
# catch help option
if ($help) {
usage;
help;
}
# catch version option
if ($script_version) {
version;
}
# connect to DB
......
......@@ -33,23 +33,43 @@ WardenCommon::loadConf($conf_file);
# FUNCTIONS
################################################################################
sub usage {
print "Usage: $RealScript [without parameters]\n";
print "Usage: $RealScript (without parameters) [-h -V]\n";
exit 1;
}
sub help {
print "$RealScript (without parameters) [-h -V]\n";
print "-h print this text and exit\n";
print "-V print version and exit\n";
exit 0;
}
sub version {
print "$RealScript: Version: $VERSION\n";
exit 0;
}
################################################################################
# MAIN
################################################################################
our ($opt_h);
our ($opt_h, $opt_V);
die usage unless getopts("h");
my $help = $opt_h;
die usage unless getopts("hV");
my $help = $opt_h;
my $script_version = $opt_V;
# catch help param
# catch help option
if ($help) {
usage;
help;
}
# catch version option
if ($script_version) {
version;
}
# superuser controle
......
......@@ -37,24 +37,32 @@ WardenCommon::loadConf($conf_file);
# FUNCTIONS
################################################################################
sub usage {
print "Usage: $RealScript -h -o -n <hostname> -r <requestor> -t <type> -c <ip_net_client> [-i <client_id>]\n";
print "Usage: $RealScript -n <hostname> -r <requestor> -t <type> -o -c <ip_net_client> [-i <client_id> -h -V]\n";
exit 1;
}
sub help {
print "$RealScript -h -o -n <hostname> -r <requestor> -t <type> -c <ip_net_client> [-i <client_id>]\n";
print "-h print this text and exit\n";
print "$RealScript -n <hostname> -r <requestor> -t <type> -o -c <ip_net_client> [-i <client_id> -h -V]\n";
print "-n hostname of receiver\n";
print "-r client registration requestor\n";
print "-t type of received events or '_any_' for receiving of all types of events\n";
print "-o enable receiving of own events\n";
print "-c CIDR of receiver\n";
print "-i user defined client ID (optional)\n";
print "-h print this text and exit\n";
print "-V print version and exit\n";
exit 0;
}
sub version {
print "$RealScript: Version: $VERSION\n";
exit 0;
}
#-------------------------------------------------------------------------------
# sendMsg - wrapper for more complex WardenCommon::sendMsg function
#-------------------------------------------------------------------------------
......@@ -72,29 +80,35 @@ sub sendMsg
################################################################################
# MAIN
################################################################################
our ($opt_n, $opt_r, $opt_t, $opt_o, $opt_c, $opt_i, $opt_h);
our ($opt_n, $opt_r, $opt_t, $opt_o, $opt_c, $opt_i, $opt_h, $opt_V);
if ($#ARGV == -1) {
usage;
}
die usage unless getopts("n:r:t:c:i:ho");
die usage unless getopts("n:r:t:c:i:ohV");
my $hostname = $opt_n;
my $requestor = $opt_r;
my $type = $opt_t;
my $ip_net_client = $opt_c;
my $client_id = $opt_i;
my $help = $opt_h;
my $script_version = $opt_V;
my $receive_own_events = "f";
if ($opt_o) {
$receive_own_events = "t";
}
# catch help param
# catch help option
if ($help) {
help;
}
# catch version option
if ($script_version) {
version;
}
# check parameters definition
switch () {
case {!defined $hostname} {WardenCommon::errMsg("Parameter 'hostname' is not defined!")}
......
......@@ -37,20 +37,27 @@ WardenCommon::loadConf($conf_file);
# FUNCTIONS
################################################################################
sub usage {
print "Usage: $RealScript -h -n <hostname> -r <requestor> -s <service> -d <description_tags> -c <ip_net_client> [-i <client_id>]\n";
print "Usage: $RealScript -n <hostname> -r <requestor> -s <service> -d <description_tags> -c <ip_net_client> [-i <client_id> -h -V]\n";
exit 1;
}
sub help {
print "$RealScript -h -n <hostname> -r <requestor> -s <service> -d <description_tags> -c <ip_net_client> [-i <client_id>]\n";
print "-h print this text and exit\n";
print "$RealScript -n <hostname> -r <requestor> -s <service> -d <description_tags> -c <ip_net_client> [-i <client_id> -h -V]\n";
print "-n hostname of sender\n";
print "-r client registration requestor\n";
print "-s name of service which sent events\n";
print "-d description tags of send events\n";
print "-c CIDR of sender\n";
print "-i user defined client ID (optional)\n";
print "-h print this text and exit\n";
print "-V print version and exit\n";
exit 0;
}
sub version {
print "$RealScript: Version: $VERSION\n";
exit 0;
}
......@@ -72,13 +79,13 @@ sub sendMsg
################################################################################
# MAIN
################################################################################
our ($opt_n, $opt_r, $opt_s, $opt_d, $opt_c, $opt_i, $opt_h);
our ($opt_n, $opt_r, $opt_s, $opt_d, $opt_c, $opt_i, $opt_h, $opt_V);
if ($#ARGV == -1) {
usage;
}
die usage unless getopts("n:r:s:d:c:i:h");
die usage unless getopts("n:r:s:d:c:i:hV");
my $hostname = $opt_n;
my $requestor = $opt_r;
my $service = $opt_s;
......@@ -86,12 +93,18 @@ my $description_tags = $opt_d;
my $ip_net_client = $opt_c;
my $client_id = $opt_i;
my $help = $opt_h;
my $script_version = $opt_V;
# catch help param
# catch help option
if ($help) {
help;
}
# catch version option
if ($script_version) {
version;
}
# check parameters definition
switch () {
case {!defined $hostname} {WardenCommon::errMsg("Parameter 'hostname' is not defined!")}
......
......@@ -37,15 +37,22 @@ WardenCommon::loadConf($conf_file);
# FUNCTIONS
################################################################################
sub usage {
print "Usage: $RealScript [-h -i <client_id>]\n";
print "Usage: $RealScript -i <client_id> [-h -V]\n";
exit 1;
}
sub help {
print "$RealScript [-h -i <client_id>]\n";
print "-h print this text and exit\n";
print "$RealScript -i <client_id> [-h -V]\n";
print "-i client_id for unregistration\n";
print "-h print this text and exit\n";
print "-V print version and exit\n";
exit 0;
}
sub version {
print "$RealScript: Version: $VERSION\n";
exit 0;
}
......@@ -67,21 +74,27 @@ sub sendMsg
################################################################################
# MAIN
################################################################################
our ($opt_h, $opt_i);
our ($opt_i, $opt_h, $opt_V);
if ($#ARGV == -1) {
usage;
}
die usage unless getopts("i:h");
my $client_id = $opt_i;
my $help = $opt_h;
die usage unless getopts("i:hV");
my $client_id = $opt_i;
my $help = $opt_h;
my $script_version = $opt_V;
# catch help param
# catch help option
if ($help) {
help;
}
# catch version option
if ($script_version) {
version;
}
# check parameters definition
if (!defined $client_id) {
WardenCommon::errMsg("Parameter 'client_id' is not defined!");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment