![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Reading specific contents from 1 input files and appending it to another input file | sksahu | Shell Programming and Scripting | 5 | 01-14-2009 06:09 AM |
| How is use sselect statement o/p in insert statement. | nkosaraju | Shell Programming and Scripting | 2 | 08-06-2008 10:26 PM |
| If statement - How to write a null statement | april | Shell Programming and Scripting | 3 | 04-16-2008 02:14 PM |
| If statement | ROOZ | UNIX for Dummies Questions & Answers | 3 | 03-09-2008 12:57 PM |
| How to prompt for input & accept input in ONE line | newbie168 | Shell Programming and Scripting | 2 | 09-27-2005 06:02 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
if statement with $1 input
Hi,
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 regards, venhart |
|
||||
|
Code:
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}"
Last edited by methyl; 01-21-2009 at 09:23 AM.. Reason: too wide |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|