Function call

Hi foiks

i am unable to find what is wrong in my code
mu functionality is to exit from shell when i give 99 but it is not calling function ext
Could you please correct me.

read option
if [ "$option" == "99" ];
   then
   ext
else 
   echo "out"
fi
        function ext
  {
  echo "tested 99 and exit is working"
  }

write the function part at the top of your code

Its working fine

---------- Post updated at 04:51 PM ---------- Previous update was at 03:35 PM ----------

Hello now i want to pass some string which always start with BDR but end charcters can be anything i just want to check if starting with BDR it must proceesd. But the script is not behaving like that

function ext
  {
   echo "THANK"
  }

function upc
  {

echo   "TO EXPORT UPROC GIVE UPROC NAME"
echo   "TO GO BACK PRESS 99"
   read parm0
   if [ "$parm0" == "BDR*" ];
      then
      $UXEXE/uxext upr upr=$parm0 output=$parm0.upr APP
      echo "$output UPROC exported"
      elif [ "$parm0" == "99" ];
      then
      start
      else
      echo "error in exporting"
     fi
  }
function start {

   echo      "FOR UPROC EXPORT PRESS 1"
   echo      "FOR SESSION EXPORT PRESS 2"
   echo      "FOR PLANNIFICATION EXPORT PRESS 3"
   echo      "TO EXIT PRESS 99"
   read option1
   if [ "$option1" == "1" ];
   then
  
   upc
   elif [ "$option1" == "2" ];
   then
   echo   "SESSION"
   elif [ "$option1" == "3" ];
   then
   echo   "PLAN "
   elif [ "$option1" == "99" ];
   then
   ext
   fi

}

echo "                                                                               *****WELCOME******                                   "
echo "                                                                       PLEASE PRESS 0 TO SERVE YOUR REQUEST                          "
echo "                                                                              TO EXIT PRESS 99                                      "
read option
if [ "$option" == "99" ];
   then
   ext
   elif [ "option" == "0" ];
   echo "mahens"
   then
   start

fi

you can't compare BDR* in if statements
use either sed or grep then depending upon exit code do whatever you want

Use case statements, something like:

case "$parm0" in
  BDR*)
    $UXEXE/uxext upr upr=$parm0 output=$parm0.upr APP
    echo "$output UPROC exported"
    ;;
  99)
    start
    ;;
  *)
    echo "Error in exporting"
esac
******************
for 
do 
    
done
***************
function upc
  {
#for i in $var
echo   "TO EXPORT UPROC GIVE UPROC NAME"
echo   "TO GO BACK PRESS 99"
   read parm0
   if [ "$parm0" == "99" ];
      then
      start
      else
      $UXEXE/uxext upr upr=$parm0 output=$parm0.upr APP
      echo "$output UPROC exported"
     fi
*****************

i want to make functionality like if it meet my if conditin than it should again ask me that DO you want uproc to export
i mean it should go to

echo   "TO EXPORT UPROC GIVE UPROC NAME"
echo   "TO GO BACK PRESS 99"

Please suggest

You can use a loop like this:

while true
do
  echo -n "press 1,2 or 99 to stop: "
  read option
  case "$option" in
    1)
      echo "1 pressed"
      ;;
    2)
      echo "2 pressed"
      ;;
    99)
      echo "STOP"
      break
      ;;
    *)
      echo "Wrong choice"
  esac
done

Have a read of a scripting tutorial:

http://www.unix.com/answers-frequently-asked-questions/13774-unix-tutorials-programming-tutorials-shell-scripting-tutorials.html

small help

how to exit from a unix for loop once inner loop is false

for i in `cat input.txt` ; do
  a=`expr $a + 1`
  echo $a
  for j in `cat mnu.txt` ; do
     b=`expr $b + 1`
     echo $b
     if [ $a == $b ];
       echo "after a=b check"
       echo $a
       echo $b
     then
       echo   "a and be are equal"
       $UXEXE/uxext tsk ses=$i vses=* upr=* model mu=$j `output=$j_$i.pnf` APP
       echo "$output PLANNIFICATION exported"
     else
       break 
     fi
   done
   echo "out of j loop"
 done

You can use a flag:

for i in `cat input.txt` ; do
  a=`expr $a + 1`
  echo $a
  for j in `cat mnu.txt` ; do
     b=`expr $b + 1`
     echo $b
     if [ $a == $b ];
       echo "after a=b check"
       echo $a
       echo $b
     then
       echo   "a and be are equal"
       $UXEXE/uxext tsk ses=$i vses=* upr=* model mu=$j `output=$j_$i.pnf` APP
       echo "$output PLANNIFICATION exported"
     else
       f=1
       break
     fi
  done
  echo "out of j loop"
  if [ $f -eq 1 ]; then
    break
  fi
done

this is correct but than fuunctionality is chaging the loop is outer loop is considering the value of a as 1 and value of b =2 so it will never meet the functionality
******************
it must be like first time both variable will be equal do the functionality
second time value of b != a so it must come out and enter the i loop
->now i must take the second line of the input file and compare it with the second line of b

Your question is not clear to me but a break within the j loop should be sufficient to terminates only the j loop.

Dear Franklin
my exact functionality is as follows:
1>the function pln must take the first line of data from the input.ksh then
2>it must take the first line of mnu.ksh and it must do
$UXEXE/uxext tsk ses=$i vses=* upr=* model mu=$j `output=$j_$i.pnf` APP
3>it must again than take the second line of input.ksh and 2 line of mnu and again it must perform
$UXEXE/uxext tsk ses=$i vses=* upr=* model mu=$j `output=$j_$i.pnf` APP

like this it must keep on doing till the end of both the files

You can do something like this:

#!/bin/sh

c=0

while read i
do
  arr[c]="$i"
  c=$(( $c + 1 ))
done < mnu.txt

c=0

while read i
do
  j=${arr[$c]}
  $UXEXE/uxext tsk ses=$i vses=* upr=* model mu=$j `output=$j_$i.pnf` APP
  c=$(( $c + 1 ))
done < input.txt