how to give a variable to a command in shell script...

hi all...
I am executing a comman in a shell script but the command needs a user input of character 'y' as input so it stops in between...may i know is there is any way of giving that character as input in the shell script itself???...thanks in advance....

Using expect is one way to deal with the interactive apps.

But i think you can also try here document style like

command <<EOF
yes
true
and_so_on
EOF

This will invoke the command and supplies the responses between <<EOF and EOF

i tried the <<EOF true EOF thing now it's not working mate.....actaully my input to the command is "y"...so i gave like my command<<EOF y EOF....this is what u said rite????

If u like to give y as user input

read x
if [ x == "y"] ; then

#write your code

else

echo "Input is wrong"

fi

you like to add the value y in the script itself

x="y"

if [ x == "y" ] ; then

#write your code

fi

no, that not what's been said.

command <<EOF
y
EOF

yeah i tried the same but it's not working:-(

What is your shell ? sh, bash, ksh, csh ....
Try this example:

script file yn.sh

echo "Confirm system destruction ?"
read confirm

if [ "$confirm" = y ]
then
   echo "System destruction confirmed."
   echo "Booom !!! "
else
   echo "Tomorrow perhaps."
fi

Excute script:

$ sh yn.sh <<EOF
y
EOF
Confirm system destruction ?
System destruction confirmed.
Booom !!! 

Jean-Pierre.