hi friends,
see the following program, unable to execute this program
the error message is 'unexpected end of file' i m new to shell programming. i typed this program in vi editor and tried to
execute unable to.
i need help can anyone explain this (as soon as possible)
regards
saru
STRING MANIPULATIONS
while [ true ]
do
printf "\n\t\tSTRING MANIPULATIONS - MENU"
printf "\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
printf "\n\t\t1 -> LENGTH OF THE STRING"
printf "\n\t\t2 -> COMPARE TWO STRINGS"
printf "\n\t\t3 -> CHANGE CASE OF THE STRING"
printf "\n\t\t4 -> CHECK FOR PALINDROME"
printf "\n\t\t5 -> EXIT"
printf "\n\n\tEnter your choice : "
read choice
case $choice in
1) sh length
;;
2) sh compare
;;
3) sh changecase
;;
4) sh palindrome
;;
5) exit
;;
*) echo ******** INVALID CHOICE ********
LENGTH
printf "\n\n\t\tPROGRAM TO FIND THE LENGTH OF STRING"
printf "\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
printf "\n\n\tEnter the string : "
read str
l=` expr length $str `
echo
echo " Length of the string = " $l
COMPARISON
printf "\n\n\t\tPROGRAM TO COMPARE TWO STRINGS"
printf "\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
printf "\n\n\t Enter the first string : "
read str1
printf "\n\n\t Enter the second string : "
read str2
if [ $str1 = $str2 ]
then
printf "\n\n\tStrings "$str1" and "$str2" are EQUAL"
else
printf "\n\n\tStrings "$str1" and "$str2" are NOT EQUAL"
fi
echo
echo
CHANGECASE
printf "\n\t\tPROGRAM TO CHANGE THE CASE OF INPUT STRING"
printf "\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
printf "\n\n\tEnter the string : "
read str
echo $str >a
tr 'a-z' 'A-Z' <a
tr 'A-Z' 'a-z' <a
PALINDROME
printf "\n\tPROGRAM TO CHECK WHETHER THE STRING IS PALINDROME OR NOT"
printf "\n\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
printf "\n\\tEnter the string : "
read str
l=` expr length $str `
i=1
j=$l
while [ $i -lt $j ]
do
s1=` expr substr $str $i 1 `
s2=` expr substr $str $j 1 `
if [ $s1 != $s2 ]
then
printf "\n\n\t\tString is NOT a PALINDROME\n\n"
exit
fi
i=` expr $i + 1 `
j=` expr $j - 1 `
done
printf "\n\n\t\tString is a PALINDROME\n\n"