Monday, January 20, 2014

Unix and Shell Programming - Getting Input Alternate from Keyboard & File

with 0 Comment
clear
echo "Getting Inputs Alternate from the keyboard"
echo "-------------------------------------------"
echo
dv='tty'
echo -e "\nEnter the file name:\c"
read file
echo
echo "Contents of the file"
echo "-------------------"
echo
cat $file
echo "OUTPUT"
echo "----------"
echo
echo ""
if[-f $file]
then
exec<$file
while read line
do
echo $line
echo -e "\nEnter your the Answer:\c"
read ans<$dv
while[-z $ans]
do
echo -e "\nEnter your the Answer:\c"
read ans<$dv
done
echo "Answer:"$ans
echo
done
else
echo "File does not exists"
fi


-----------
OUTPUT:
-----------
Getting Inputs Alternate from the Keyboard
--------------------------------------------
Enter the file name:ques

Contents of the file
-------------------
1.What is your name?
2.What is your friend name?
3.What you finished your programs?

OUTPUT
----------
1.What is your name?
Enter your the Answer: Ashok
Answer:Ashok

2.What is your friend name?
Enter your the Answer:Raji
Answer:Raji

3.When you finshed your programs?
Enter your the Answer:yes
Answer:yes

0 comments:

Post a Comment

Powered by Blogger.

Blog Archive