shell script with decision making


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting shell script with decision making
# 1  
Old 06-14-2012
shell script with decision making

Hi all
I need help for the issue below.
I need to create script:
Code:
FORM_cmd=query || import
FORM_command=add
FORM_msisdn=389881234567
FORM_provcode=SK
FORM_attr=12

FORM_cmd can be "query" or "import"
when FORM_cmd="query" then execute -> spdci -cmd $FORM_cmd FORM_cmd

when FORM_cmd="import" then execute -> echo $FORM_command  $FORM_msisdn:$FORM_provcode=$FORM_attr > /tmp/tmp.txt | spdci -cmd  $FORM_cmd /tmp/tmp.txt

Thank you in advance

Last edited by Scrutinizer; 06-14-2012 at 05:56 AM.. Reason: Code tags also for pseudocode
# 2  
Old 06-14-2012
Quote:
Originally Posted by vasil
when FORM_cmd="query" then execute -> spdci -cmd $FORM_cmd FORM_cmd

when FORM_cmd="import" then execute -> echo $FORM_command $FORM_msisdn:$FORM_provcode=$FORM_attr > /tmp/tmp.txt | spdci -cmd $FORM_cmd /tmp/tmp.txt[/CODE]

Thank you in advance

Code:
if [ "$FORM_cmd" = "query" ]; then
 spdci -cmd $FORM_cmd FORM_cmd
elif [ "$FORM_cmd" = "import" ]; then
 echo $FORM_command  $FORM_msisdn:$FORM_provcode=$FORM_attr > /tmp/tmp.txt
 spdci -cmd  $FORM_cmd /tmp/tmp.txt
else 
 echo invalid FORM_cmd
fi

# 3  
Old 06-14-2012
Thank you for the quick answer. The script works perfectly.
# 4  
Old 06-14-2012
How about using a case statement:

Code:
case "$FORM_cmd" in
    query) spdci -cmd $FORM_cmd FORM_cmd ;;
    import)
       echo $FORM_command  $FORM_msisdn:$FORM_provcode=$FORM_attr > /tmp/tmp.txt
       spdci -cmd  $FORM_cmd /tmp/tmp.txt ;;
    *) echo invalid FORM_cmd ;;
esac

Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Handling decision making logic

------- Output Screen -------- Choose the option ----------------- 1.Input 2.Output 3.CFT Uniq x.Exit ----------------- 2 Enter the Output flow IDF PBL5572U Enter the Output existing flow IDF PBL5198H sf_PBL5572U.cmd file exist in invalid path or doesn't exist (0 Replies)
Discussion started by: Vijaykannan T
0 Replies

2. Shell Programming and Scripting

Using shell scripting for making queries on postgres sql

I have a situation where I have a list of airplanes that make a series of flights. Therefore I am looking up the different flights that each airplane makes based on a postgres sql query: select flightid from plane where airplane='DELTAx' As a result I get a series of flight numbers... (0 Replies)
Discussion started by: JSNY
0 Replies

3. Shell Programming and Scripting

Query on decision making...

is_number() { echo $1|egrep '^*$' 2>&1 1>/dev/null return $? }why the following snippet always give an output as "no" and never "yes" whatever the parameter I give to function is_number? if ]; then echo yes; else echo no; fi In addition, the function is_number() is... (5 Replies)
Discussion started by: biglau
5 Replies

4. Shell Programming and Scripting

Making file inside shell script

Hi, i have written a shell script and its working fine till now. Now, i have to enhance it with a small updation. i need to make a file inside my file that will contain the below parameters 1) Customer_id 2) Server_id 3) No. Account All the above variables are already been taken in... (3 Replies)
Discussion started by: dazdseg
3 Replies

5. Shell Programming and Scripting

making shell script

Hi , I am new to shell scripting I want to make script as to execute followng command mysqldump -u (user name) -p(password) database name>filename.sql this file saves with current date and time and execute automatically at particular time which I give (10 Replies)
Discussion started by: kaushik02018
10 Replies

6. Shell Programming and Scripting

Problem in making shell script

Dear all Dear Brother I am bit new to programming or shell scripting. I have given one shell script which is regarding combining all the 240 or less files in a particular folderwhich is related to one hour of the day. There will be 24 these kind of folders related to a day . It means there... (4 Replies)
Discussion started by: girish.batra
4 Replies

7. Shell Programming and Scripting

Need help making a script

Here is what I have: #!/bin/bash # Setup year date and month YR=`date +%Y '{print $6}'` MON=`date +%b '{print $2}'` DAY=`date +%d '{print $3}'` file=$YR$MOY$DOM # clear # Dump database using USER/PASS to ..sql mysqldump --user=me -ppass database > database-db.$file.sql The YR, MON and... (2 Replies)
Discussion started by: npereira
2 Replies

8. Shell Programming and Scripting

Making a SOAP call from within unix shell scripts

Hi guys, Is it possible to make SOAP calls from within Unix shell scripts? I need to access a web service from within UNIX in order to lookup something while I am doing some parsing on a file. Regards, Laud (2 Replies)
Discussion started by: Laud12345
2 Replies
Login or Register to Ask a Question