Please could someone advise me what I'm doing wrong here ?
( I'm using bourne shell - sh )
if
$1=BillingReport01
then
STARTUP_LOG=/Gateway01/FIXGW/var/log/logwatcher_$1.startup.$DATE.log
elif
$1=BillingReport02
then
STARTUP_LOG=/Gateway02/FIXGW/var/log/logwatcher_$1.startup.$DATE.log
fi
As posted there are syntax errors. The syntax for if would normally start
if [ condition ]
then
It is best to save the script parameter $1 into a named variable at the earliest opportunity.
On some unixes the variable "DATE" is reserved. You do not seem to be setting the variable.
This type of processing is easier to follow with a case statement.
In this example I have replaced $DATE with $YYYYMMYY - the reversed date. Your version will of course be different.
Beware that if the process is run more than once per calendar day the filename is not unique.
Billing="$1"
YYYYMMDD="`date +%Y%m%d`"
#
#
case "${Billing}" in
"BillingReport01")
STARTUP_LOG="/Gateway01/FIXGW/var/log/logwatcher_${Billing}.startup.${YYYYMMDD}.log"
;;
"BillingReport02")
STARTUP_LOG="/Gateway02/FIXGW/var/log/logwatcher_${Billing}.startup.${YYYYMMDD}.log"
;;
*)
echo "Invalid Billing Parameter: ${Billing}"
exit
;;
esac
#
echo "${STARTUP_LOG}"