Handling decision making logic


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Handling decision making logic
# 1  
Old 05-02-2017
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
diff: input file /apps/cftpkg2b/3.1.3/filusr/sf_PBL5572U.cmd: No such file or directory
The sf_PBL5572U.cmd coding is correct

Coding:

Code:
  
 echo "******CFT CHECKS********"
 echo "Choose the option"
 echo "-----------------"
echo      1.Input
echo      2.Output
echo      3.CFT Uniq
echo      x.Exit
echo "-----------------"
 read opt
case $opt in
         1) echo "1"
         ##find /apps/cftpkg2b/3.1.3/filusr/  -name *$1* -exec ls -ltr {} \; 2>/dev/null
        ;;
         2) echo "2"
           echo "Enter the  Output  flow IDF"
           read i
           echo '\n'
           echo "Enter the Output existing flow IDF"
           read j
           echo '\n'
         if [ -s /apps/cftpkg2b/3.1.3/filusr/sf_"$i.cmd" ]
         then
         echo "sf_"$i.cmd" file exist"
         else
         echo "sf_"$i.cmd" file exist in invalid path or doesn't exist"
          fi
         diff  /apps/cftpkg2b/3.1.3/filusr/sf_"$i.cmd" /apps/cftpkg2b/3.1.3/filusr/sf_"$j.cmd" > COMPFILE1
                 if [ -s COMPFILE1 ]
                 then
                 cat COMPFILE1
                 echo "Cross verify the   sf_"$i.cmd"  codes "
                 else
                 echo "The sf_"$i.cmd" coding is correct"
                #find /apps/cftpkg2b/3.1.3/filusr/ -name "*$i*" -exec ls -ltr {} \; 2>/dev/null > out_file2.txt
                fi
         ;;
        3) echo "3" ;;
        x|X) break ;;
        *)echo "Invalid output" ;;

Please look at the above coding and output.

The ultimate aim of the program is finding the difference in two files on the location /apps/cftpkg2b/3.1.3/filusr.


What I have done is

(consider only option 2)

1. input of first file
2. Input of second reference file (usually standard couple of files).
3. Checking the existence of input file in mentioned path.
if file exist, then display the file and find the difference between the files.
4. if there is a difference moving the difference into a new file(COMPFILE1).

and later manually we will check the difference and correct the file.


Now problem is in case the user gives the different file name and if the second input reference file is not available on that path , no difference is shown and user may think there is not difference in file contents. So this logic goes wrong .Please help to handle.

Last edited by Vijaykannan T; 05-02-2017 at 10:51 PM.. Reason: corrections
Login or Register to Ask a Question

Previous Thread | Next Thread

2 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script with decision making

Hi all I need help for the issue below. I need to create script: 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... (3 Replies)
Discussion started by: vasil
3 Replies

2. 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
Login or Register to Ask a Question