Sponsored Content
Full Discussion: if statement with $1 input
Top Forums Shell Programming and Scripting if statement with $1 input Post 302278811 by methyl on Wednesday 21st of January 2009 08:21:32 AM
Old 01-21-2009
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
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If statement - How to write a null statement

In my ksh script, if the conditions of a if statement are true, then do nothing; otherwise, execute some commands. How do I write the "do nothing" statement in the following example? Example: if (( "$x"="1" && "$y"="a" && "$z"="happy" )) then do nothing else command command fi... (3 Replies)
Discussion started by: april
3 Replies

2. Shell Programming and Scripting

How is use sselect statement o/p in insert statement.

Hi All, I am using Unix ksh script. I need to insert values to a table using the o/p from a slelect statement. Can anybody Help! My script looks like tihs. ---`sqlplus -s username/password@SID << EOF set heading off set feedback off set pages 0 insert into ${TB_NAME}_D... (2 Replies)
Discussion started by: nkosaraju
2 Replies

3. Shell Programming and Scripting

KSH - How to use a file as input to an IF or AWK statement

Hi, I have a ksh script where I have an awk statement to exclude a few items... but my "few items" has now grown substantially and I'm looking for a nice compact way of doing this. Maybe putting the exceptions into a file or something? Any suggestions greatly appreciated. # Excluded items... (1 Reply)
Discussion started by: right_coaster
1 Replies

4. Shell Programming and Scripting

redirect input within case statement?

I'm trying to run the logic below but get a `<' is not matched error message when I return a Y or y; printf "Run this ? : " read RESP case $RESP in Y|y) cat <<EOF > file today is Monday EOF ;; N|n) exit 1 ;; esac Any ideas? (2 Replies)
Discussion started by: h8mmer
2 Replies

5. Shell Programming and Scripting

!!VERY URGENT!! Trouble in getting user input, while using under CASE statement in UNIX

i want to get user input like this please tell which option to chose 1. mango 2. tango 3. rango if user chooses mango then it should execute a set of statements and again ask like this what do you want to do 1.add 2.subtract 3.exit when i choose exit it should goto my previous... (1 Reply)
Discussion started by: s.deepak
1 Replies

6. Shell Programming and Scripting

Trouble in getting user input while using CASE statement in UNIX

i want to get user input like this please tell which option to chose 1. mango 2. tango 3. rango if user chooses mango then it should execute a set of statements and again ask like this what do you want to do 1.add 2.subtract 3.exit when i choose exit it should goto my previous menu... (4 Replies)
Discussion started by: s.deepak
4 Replies

7. Shell Programming and Scripting

Read input files and merge them in given order and write them to input one param or one file

Dear Friends, I am looking for a shell script to merge input files into one file .. here is my idea: 1st paramter would be outfile file (all input files content) read all input files and merge them to input param 1 ex: if I pass 6 file names to the script then 1st file name as output file... (4 Replies)
Discussion started by: hyd1234
4 Replies

8. Shell Programming and Scripting

Update Statement User menu input screen

Hi Guys, Any good reference for me to perform user database update statement on table which has quite number of fields could be updated depend on user specified column name and the value to assign. All the approaches are welcome and appreciated. Thanks. (1 Reply)
Discussion started by: ckwan123
1 Replies

9. Shell Programming and Scripting

Convert Update statement into Insert statement in UNIX using awk, sed....

Hi folks, I have a scenario to convert the update statements into insert statements using shell script (awk, sed...) or in database using regex. I have a bunch of update statements with all columns in a file which I need to convert into insert statements. UPDATE TABLE_A SET COL1=1 WHERE... (0 Replies)
Discussion started by: dev123
0 Replies

10. Shell Programming and Scripting

Bash read input in case statement not working as expected

I'm having an issue with bash read input when using a case statement. The script halts and doesn't read the input on the first loop. if I hit enter then the scripts starts to respond as expected. Need some help here. defaultans=8hrs read -e -i $defaultans -p "${bldwht}How long would you like... (5 Replies)
Discussion started by: woodson2
5 Replies
CRASHMAINT(1)							     CrashMail							     CRASHMAINT(1)

NAME
crashmaint - Do maintanence on CrashMail message bases SYNOPSIS
crashmaint [MAINT] [PACK] [VERBOSE] [SETTINGS filename] [PATTERN pattern] DESCRIPTION
Deletes old messages according to KEEPNUM and KEEPDAYS in crashmail.prefs. The program can do two different operations on a messagebase, MAINT and PACK. The meaning of these two modes are different for different messagebase formats. *.msg MAINT deletes messages and PACK renumbers the area. JAM MAINT sets the Deleted flag for the messages. PACK removes all messages with the Deleted flag from the messagebase. Both MAINT and PACK can be specified at the same time. OPTIONS
SETTINGS filename Specifies that another config file than the default should be used. You can use the environment variable CMCONFIGFILE to set the default configuration file. PATTERN pattern Lets you perform the operations on only some of your areas. VERBOSE Gives you a lot of information which you don't really need. EXAMPLES
crashmaint MAINT PACK PATTERN R20_AMIGA* SEE ALSO
crashmail(1) AUTHOR
CrashMail is written by Johan Billing <billing@df.lth.se> This manual page was written by Peter Karlsson <peter@softwolves.pp.se> Johan Billing 1999-08-01 CRASHMAINT(1)
All times are GMT -4. The time now is 11:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy