#!/bin/bash
usage()
{
cat << EOF
usage: $0 options
This script genrates the report in xls format.
OPTIONS:
-h Show this message
-s Start date for the report(format: yyyy/mm/dd).
-e End date for the report(format: yyyy/mm/dd).
-m hostname fot which report is generated
-f hostfile(each host in new line)
Don't specify option(m,f) if you need to generate for all hosts.
EOF
}
start_date=
end_sate=
host_name=
host_file=
while getopts "hs:e:m:f" OPTION
do
case $OPTION in
h)
usage
exit 1
;;
s)
start_date=$OPTARG
;;
e)
end_date=$OPTARG
;;
m)
host_name=$OPTARG
;;
f)
host_file=$OPTARG
;;
?)
usage
exit
;;
esac
done
if [ -z $start_date ]
then
echo "Please specify start date for the report"
usage
exit
elif [ -z $end_date ]
then
echo "Please specify end date for the report"
usage
exit
fi
if [[ -n "$host_name" && -n "$host_file" ]]
then
echo "Please specify either single hostname or host file for the report"
usage
exit
fi
echo $start_date
echo $end_date
echo $host_name
echo $host_file
Cant figure out why its not working.
---------- Post updated 08-17-11 at 12:30 AM ---------- Previous update was 08-16-11 at 04:30 AM ----------