help with script parameter checking based on environment


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help with script parameter checking based on environment
# 1  
Old 04-17-2012
help with script parameter checking based on environment

I need to check if the parameters are correctly passed based on the Environment I am in.

For e.g when I am in dev the 1st paramter needs to be either A OR B OR C OR D
similarly when I am in qa the parameter needs to be either e or f

so i need to write a case staement or a if statement to acheive this

I wrote a case statement as below. SIEBELENV is an environment variable from the .profile

Code:
case $SIEBELENV in
        DEV)       SERVER_PATH="A|B|C|D" ;;
        QA)        SERVER_PATH="E|F" ;;
        *)    echo "$(date). Invalid ENV variable $SIEBELENV. Please check environment variable file." >> $LOG_FILE
                    rc=2
                    return $rc
                    exit ;;
esac

I have set the paths correctly based on the enviroment. but I need to make sure when the script runs in dev with a parameter equal to any of the FTP paths set for dev from case statment then only proceed
otherwise send an mail saying wrong parameters based on environment.

for e.g script would be called like this interface.ksh A g4 ( A is the SERVER_PATH ). I need to see if this is running in dev it should accept only either A or B orc or D

Otherwise throw an error that environment and paramter doesn't match

How can I do this

Last edited by Corona688; 04-17-2012 at 03:29 PM..
# 2  
Old 04-17-2012
You can put a case statement inside your cases, or you can smoosh the variables together to make it one big case:

Code:
case "$SIEBELENV:$SERVER_PATH" in
        DEV:[ABCD]) ;;
        QA:[EF]) ;;
        *)
                echo "Invalid combination of $SIEBELENV with $SERVER_PATH"
                exit 1
                ;;
esac

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Call script parameter based on dates

Hi Guys, I am having a script which needs to be iterated based on date passed and itrate based on no of months given. #!/bin/bash var_d=$1 months=$2 sh invoke_script var_d i need to iterate the inside script something like below sh invoke_script 170101 sh invoke_script... (4 Replies)
Discussion started by: Master_Mind
4 Replies

2. UNIX for Dummies Questions & Answers

Best Alternative for checking input parameter contains required value or not

Any good way to check if code has the required output # /sbin/sysctl net.ipv4.icmp_echo_ignore_broadcasts net.ipv4.icmp_echo_ignore_broadcasts = 1 /sbin/sysctl net.ipv4.icmp_echo_ignore_broadcasts | grep "= 1" net.ipv4.icmp_echo_ignore_broadcasts = 1 What I can think of is above, and it... (16 Replies)
Discussion started by: alvinoo
16 Replies

3. Shell Programming and Scripting

Call Script with Parameter (that has another parameter)

Hi. How do I achieve this sh /EDWH-DMT02/script/MISC/exec_sql.sh "@/EDWH-DMT02/script/others/CSM_CKC/Complete_List.sql ${file_name}" Complete_List.txt The /EDWH-DMT02/script/MISC/exec_sql.sh has two parameters and it's working fine with this sh /EDWH-DMT02/script/MISC/exec_sql.sh... (7 Replies)
Discussion started by: aimy
7 Replies

4. Shell Programming and Scripting

Last date of month based on parameter

Hi All, How do i get the last date of a month in Unix based on a parameter value. My requirement is if i pass 03/05/2014 as parameter, then i shud get the output/return value as 2/28/2014 If i pass 03/31/2014 as parameter, the output/return value should be 03/31/2014 itself. Also,... (2 Replies)
Discussion started by: galaxy_rocky
2 Replies

5. Shell Programming and Scripting

Passing parameter to script, and split the parameter

i am passing input parameter 'one_two' to the script , the script output should display the result as below one_1two one_2two one_3two if then echo " Usage : <$0> <DATABASE> " exit 0 else for DB in 1 2 3 do DBname=`$DATABASE | awk -F "_" '{print $1_${DB}_$2}` done fi (5 Replies)
Discussion started by: only4satish
5 Replies

6. Shell Programming and Scripting

Checking for ranges based on 2 columns

Hi, I have a file with 6 columns. I want to check if column 1 and 2 fall between column 5 and 6 I want to call them as "TRUE_genes" if not then call them as "FALSE_genes". I can do it for checking one column but how to mention about two columns. file1 110371373... (1 Reply)
Discussion started by: Diya123
1 Replies

7. Shell Programming and Scripting

run the file based on environment

Hi, I needed to run a script based on the environment..I'm just having some issue with the script..can someone help me ? #!/bin/ksh pat01=`uname -a | awk '{printf "%s", $2}'` #if it is server 1 run this file if ; then echo "run this file" #if it is server 2 run this file... (5 Replies)
Discussion started by: moe458
5 Replies

8. UNIX for Dummies Questions & Answers

checking if parameter passed is a number

I have written a function that fills an array and another function where if a parameter is supplied it will jump to that part of the array and cat it to the screen. I need to put in some checks to make sure the parameter supplied is firstly a number and then not a number great than the length of... (2 Replies)
Discussion started by: magnia
2 Replies

9. UNIX for Dummies Questions & Answers

checking parameter values passed to script

Hi, I will pass 3 parameters for a script.I have to check the file name and create a new file name with time stamp. the parameters which i'm passing are /dir/stg/filename.txt /dir/path/head.txt /dir/path/tail.txt Now i have to check filename like : if it is a.txt i have to create... (2 Replies)
Discussion started by: ammu
2 Replies

10. Shell Programming and Scripting

Parameter Checking

Hi all, My script has 2 mandatory and 1 optional paramter. If the third parameter(optional) one is null the it should take a default value say 3. Can any one please write a simple code. sh test.sh 1 2 3 var1=$1 var2=$2 if then var3=3 fi echo " the third variable $var3" ... (1 Reply)
Discussion started by: ammu
1 Replies
Login or Register to Ask a Question