#!/bbs/opt/bin/csperl5.12 use strict; no strict "refs"; use warnings; use File::Compare; use File::Basename; use IO::File; use Sys::Hostname; use Data::Dumper; use Tie::File; use Encode; use lib "/bbsrc/bin/prod/lib/site_perl"; use JSON::XS qw( decode_json ); use Getopt::Long; sub usage { my $prog = basename $0; print <<_USAGE_END; Usage:: $prog -h | | [-v] [ --validate] --verbose | -v Run tool in verbose mode. --help | -h Usage information. --validate | -V Validate Json object and Validate this against Json schema. --conf | -c Json object file location --output | -o Output location for nfs mount report --log | -l Output logfile location. --tag | -t Generate output file for all nfs mounts for a particular tag. --mount | -m Specify mountpoint name for example software, tools etc: This will generate an output file detailing all mounts that are required for the current server this tool is being executed on. --host | -H Specify a server hostname and this tool will generate a report detailing every single nfs mount that is required on that particular server. _USAGE_END } sub getoptions { my %opts = qw( verbose 0 ); Getopt::Long::Configure("bundling"); unless ( GetOptions ( \%opts, qw[ verbose|v help|h validate|V conf|c=s output|o=s log|l=s tag|t=s mount|m=s host|H=s ] ) ) { usage(); exit 1; } usage(), exit 0 if $opts{help}; if (!@ARGV) { print "Error:: No arguments specified to $0.\n"; usage(); exit 1; } return \%opts; } #----------------------------------------------------------- MAIN: { my $opts = getoptions(); } #### sub extract_json { my $file = shift; local $/; #enable slurp open my $fh, "<", "$file"; my $json = <$fh>; return $json; } my $json_data = extract_json("$master_conf"); my $decoded_json_obj = decode_json( $json_data);