LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 03: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, 04:59 AM   #2
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
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, 05:35 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Code:
[ "$choice = "" ] && continue
odd num (3) of double-quotes ...
 
Old 01-15-2010, 03: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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:49 AM.

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