LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-14-2010, 04:54 AM   #1
kevmcool
Member
 
Registered: Dec 2009
Location: London
Distribution: CentOS
Posts: 36

Rep: Reputation: 15
Can using vi in runlevel 3 then runlevel 5 cause syntax errors?


Hello
Here's my problem
I am using RHEL5 Server on an i686 machine in runlevel 3
Creating a bash script using vi
Running the script in vi as I go, to iron out any problems
I startx to get a print of what I've done so far, I like to see the highlighting
I carry on writiing my script in vi in the gui, and start getting syntax errors
That was previously error free
I hashed out the line with the errors and the while loop but it makes no difference
If I hash out the offending last line, how can I get an error in that line?
I should probably include the script
Its basically a case statement in a while loop

#!/bin/bash
#
# A script for the VTC shell scripting course
###################################################
#
# The VTC Database
#
#####################################################
#
# Define the name of the file
#
fname=names.txt

#
#
# If this file does not exist create it
#
[ ! -f $fname ] && > $fname


#
# Start a forever loop
#
while true
do
#
# Present the user with a list of options
#
clear
echo WELCOME TO THE VTC DATABASE
echo
echo Please select one of the following options:
echo
echo 1. Create a record
echo 2. View records
echo 3. Search for records
echo 4. Delete records that match a pattern
echo
echo -n Enter number or type q to quit ?
read choice junk
#
#
# Empty answers cause menu to redisplay
#
[ "$choice = "" ] && continue

#
# The options are constructed as a case statement
#
case $choice in
#
#
# Option 1. Create a record
#
#
1)
echo
echo WELCOME TO THE VTC DATABASE
echo
echo "Please enter the following details: "
echo
echo -n "First Name: " ;read name
echo -n " Surname: " ;read sur
echo -n " Address: " ;read add
echo -n " Borough: " ;read boro
echo -n " City: " ;read city
echo -n " Postcode: " ;read post # line 67
#
# Send the above details to names.txt
#
echo
echo $name:$sur:$add:$boro:$city:$post >> $fname
;;
#
#
#####################################################
#
# Option 2. View records
#
2)
echo
echo These are the contents of the VTC Database
echo
cat $fname | more
#
# Display the number of entries
#
echo
echo There are `wc -l < $fname` entries in the VTC Database
;;
#
#
#######################################################

3)
echo This option is not implemented yet
;;

4)
echo This option is not implemented yet
;;
q*|Q*)
exit 0
;;
*)
echo Please try again
;;
esac
done # line 110

The errors I get are as follows
line 67: unexpected EOF while looking for matching `"'
line 110: syntax error: unexpected end of file
If the problem is with the script thats ok
My question is,
Can a change like, I have described above cause syntax errors that you can't see?
Thanks
 
Old 01-14-2010, 05:59 AM   #2
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,674
Blog Entries: 29

Rep: Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917
I faced such problem once, not in vi though !

All I did that time was to re-write the each line of the code again !
My code was small !!

It solved the problem !
 
Old 01-14-2010, 06:35 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
Code:
[ "$choice = "" ] && continue
odd num (3) of double-quotes ...
 
Old 01-15-2010, 04:26 AM   #4
kevmcool
Member
 
Registered: Dec 2009
Location: London
Distribution: CentOS
Posts: 36

Original Poster
Rep: Reputation: 15
Thanks for the input folks
good spot Chrism01
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
What's the difference between runlevel 2 and runlevel 5 in Debian? davidas Linux - Newbie 2 01-05-2012 02:10 PM
Problems starting runlevel 3 , redhat 7.3, "no more processes left in this runlevel" kiyoshi Linux - Software 1 06-25-2009 06:11 AM
New Install of PCLinuxOS boots into runlevel 3. Should be runlevel 5 MonctonJohn Linux - General 4 02-01-2008 05:38 PM
Go into runlevel 3 after a runlevel 4 crash davidguygc Linux - General 1 08-24-2007 09:23 PM
Soun Mixer absent in Runlevel 3 but present in Runlevel 5 debloxie SUSE / openSUSE 1 01-18-2006 10:15 AM


All times are GMT -5. The time now is 07:15 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration