LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-28-2007, 09:10 AM   #1
saru06
LQ Newbie
 
Registered: Jul 2007
Posts: 2

Rep: Reputation: 0
shell programming


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"
 
Old 07-28-2007, 04:29 PM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
saru06: You should include code in code blocks when posting. It is harder to read code when the indenting is lost.
Look for a missing esac and done statements in the first program.

Also read the man page for "test". You are using "=" when you want to use "==".
 
Old 08-09-2007, 01:02 AM   #3
saru06
LQ Newbie
 
Registered: Jul 2007
Posts: 2

Original Poster
Rep: Reputation: 0
hello friends

which editor should i use to edit xml coding, how to save it(extension) and how to see the output.

I tried with notepad ans extension .xml but i can see the same coding appering in ie when i opened that file in internet explorer.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
X11R72: configure fails due to unexpected end of file? ichrispa Linux - Software 0 07-28-2007 07:00 AM
bash "unexpected end of file" script error Runge_Kutta Linux - General 6 05-23-2007 03:36 PM
/usr/bin/lesspipe: line 223: syntax error: unexpected end of file fakie_flip Linux - Software 1 09-06-2006 02:22 AM
Unexpected end of file??? raid517 Linux - Software 2 12-01-2004 04:10 AM
ACPI: Unexpected end of file h1tman Slackware 6 09-08-2003 04:40 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration