Read statement not working in a script

I have a script consisting of certain functions whose input is a file at same location. In that file i have written the name of anothe file at same location. The third file contains a word which act as a function in the first script.Let me give an example
i have a scrip file say 1.sh in which i am reading the contents of file b line wise. let say contents of b is Run Pause. Pause is a third file whose content is Suspend.
so in 1.sh i am extracting the keyword Suspend and then calling a script halt .sh who content is

echo "Press y to continue"
while read ans
do
  if [ $ans = 'y' ]
  then
    exit 1
  else
    echo "Incorrect entry"
  fi
done
echo "Exiting"

Now here the script doesnt stop at read and continue executing till the last.Pls tell what should i do in this case?

Hi,

I have tried your code and its executing fine..
According to your code when you type y(input) it is exiting and when you type any different character other than y it is in the continuous loop.

hi Anjan1
have u tried executing the code in the same way as i have described. bcoz if you execute it directly it works fine but if you do it as i have tod its giving problem.
try it in this wway
make i file 1.sh having content

cat $1 | while read LINE
arg=`echo $LINE | cut -f 1 -d' '`
if [ $arg = 'Run' ]
then
cat $arg | while read LINE1
arg1= `echo $LINE1 | cut -f 1 -d' '`
if [ $arg1 = 'Suspend' ]
then
sh halt.sh
fi
fi

make a file a having content
Run Pause

Make a file Pause having content
Suspend

now execute
1.sh a

Hi Sumit,

Can you please tell us for what u r using $1 and why u r trying to open that $1. So that it will easy for us to valiadate the code.

Thanks,
Subhendu

Your code is not complete .. you didn't put the "do&done" in while syntax as
below in red bold font

cat $1 | while read LINE
do
arg=`echo $LINE | cut -f 1 -d' '`
if [ $arg = 'Run' ]
then
cat $arg | while read LINE1
do
arg1= `echo $LINE1 | cut -f 1 -d' '`
if [ $arg1 = 'Suspend' ]
then
sh halt.sh
fi
done
fi
done

hi all
that $1 is actually file with name a whose contents i have mentioned.
what i am trying here is that i am reading the contents of file a line by line and then taking appropriate action depending upon the contents of a.

P.S: regarding 'done; in my code,it is there.I forgot to add it in the code i published here.

Guys
Pls help me in this.
I havnt got the solution yet.

tried running your code as directed by you.
seems like,

 
$ cat a
Run Pause
 
$ cat Pause
Suspend
 
$ cat 1.sh
#!/bin/bash
cat $1 | while read LINE
do
  arg=`echo $LINE | cut -f 1 -d' '`
  if [ $arg == 'Run' ]
    then
    cat $arg | while read LINE1
    do
        arg1=`echo $LINE1 | cut -f 1 -d' '`
        if [ $arg1 == 'Suspend' ]
           then
           sh halt.sh
        fi
    done
  fi
done
 
$ sh 1.sh a
cat: Run: No such file or directory

file named Run not found at 1st run
created a file: Run with content "Suspend"

$ echo Suspend > Run
 
$ cat Run
Suspend
 
$ sh 1.sh a
sh: halt.sh: No such file or directory

Created an empty halt.sh

$ touch halt.sh
 
$ sh 1.sh a
 

One thing i noticed in your code is

arg1= `echo $LINE1 | cut -f 1 -d' '`

There should not be any space inbetween.