LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux > Linux - Newbie
User Name
Password
Linux - Newbie This 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

Tags used in this thread
Popular LQ Tags , , , , ,

Reply
 
Thread Tools
Old 10-23-2009, 06:33 AM   #1
chisunum
LQ Newbie
 
Registered: Oct 2009
Posts: 1
Thanked: 0
Post why is my shell script giving me - syntax error near unexpected token 'enterInfo()


[Log in to get rid of this advertisement]
#!
enterInfo()
{
empID=10
while [ $empID -lt 5000000000000 ]
do
echo "ENTER EMPLOYEE DETAILS FOR WHICH EMPLOYEE ID IS: $empID"
echo
echo
echo
echo
echo -n "ENTER EMPLOYEE FIRST NAME:"
read fname
while true
do
if [ -z $fname ]
then
echo "EMPLOYEE FIRST NAME CANNOT BE BLANK."
continue
else
break
fi
done
echo -n "ENTER EMPLOYEE LAST NAME:"
read lname
while true
do
if [ -z $lname ]
then
echo "EMPLOYEE LAST NAME CANNOT BE BLANK."
continue
else
break
fi
done
echo -n "ENTER EMPLOYEE DATE OF BIRTH:"
read dob
while true
do
if [ -z $dob ]
then
echo "EMPLOYEE DATE OF BIRTH CANNOT BE BLANK."
continue
else
break
fi
done
echo -n "ENTER EMPLOYEE DATE OF JOINING:"
read doj
while true
do
if [ -z $doj ]
then
echo "EMPLOYEE DATE OF JOINING CANNOT BE BLANK."
continue
else
break
fi
done
echo -n "ENTER EMPLOYEE DEPARTMENT:"
read dept
while true
do
if [ -z $dept ]
then
echo "EMPLOYEE DEPARTMENT CANNOT BE BLANK."
continue
else
break
fi
done
echo -n "ENTER EMPLOYEE GRADE:"
read grade
while true
do
if [ -z $grade ]
then
echo "EMPLOYEE GRADE CANNOT BE BLANK."
continue
else
break
fi
done
typeset -i bsalary
echo -n "ENTER EMPLOYEE BASIC SALARY:"
read bsalary
while true
do
if [ -z $bsalary ]
then
echo "EMPLOYEE BASIC SALARY CANNOT BE BLANK."
continue
else
break
fi
done
typeset -i allow
typeset -i deduction
typeset -i gsalary
case ${grade} in
"SSK") allow=bsalary\*0.2
deduction=bsalary\*0.1
gsalary=$((bsalary+allow)) - deduction
"HSK") allow=bsalary\*0.2
deduction=bsalary\*0.12
gsalary=$((bsalary+allow)) - deduction
"SK") allow=bsalary\*0.2
deduction=bsalary\*0.13
gsalary=$((bsalary+allow)) - deduction
"SMSK") allow=bsalary\*0.2
deduction=bsalary\*0.15
gsalary=$((bsalary+allow)) - deduction
"UNSK") allow=bsalary\*0.18
deduction=bsalary\*0.15
gsalary=$((bsalary+allow)) - deduction
esac
echo -n "ENTER EMPLOYEE DATE OF RETIREMENT:"
read dor
while true
do
if [ -z $dor ]
then
echo "EMPLOYEE DATE OF RETIREMENT CANNOT BE BLANK."
continue
else
break
fi
done
echo "empID: fname: lname: dob: doj: dept: grade: bsalary: dor: gsalary" >> employeeMaster
done
return
}
enterInfo
windows_xp_2003 chisunum is offline  
Tag This Post , , , , ,
Reply With Quote
Old 10-23-2009, 07:38 AM   #2
fusion1275
Member
 
Registered: Jul 2007
Posts: 142
Thanked: 6
You can always start by defining what shell to use. I dont think
Quote:
#!
will work.

Just a good starting point.
windows_xp_2003 fusion1275 is offline     Reply With Quote
Old 10-23-2009, 07:42 AM   #3
bigrigdriver
Senior Member
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: openSUSE 10.3 Debian 4.0
Posts: 4,654
Thanked: 12
if you are using the bash shell, #! should be #!/bin/bash
linux bigrigdriver is offline     Reply With Quote
Old 10-23-2009, 04:37 PM   #4
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835
Thanked: 136
Quote:
Originally Posted by chisunum View Post
[-- snip --]
  • Repost your script using the provided CODE tags, so it will indent properly. This assumes that the original has any indentation.
  • The error message you provide refers to your entire function enterInfo(), e.g. all of it. In other words, the error message has no value.
  • I tried running your script. The number of errors is too great to list in a finite-length post, so the original error message was right. It is fair to say that, to a first approximation, the script is all error. So here is my advice:
  1. Write a script consisting of one line.
  2. Test that one line and satisfy yourself that it does what you expected. Do not proceed to step (3) until that one line works as expected and that you understand why it works.
  3. Add one more line to your script and repeat step(2).
  4. Do not ever write hundreds of lines of code before establishing that you can write one line.
  5. Learn what a subroutine is, and use this wonderful ideas as often as possible. An entire script that is a single subroutine, especially one that doesn't work, doesn't count.
linuxfedora lutusp is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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
sh: syntax error near unexpected token `(' venkatesh_b Linux - Newbie 1 05-16-2009 06:44 AM
Syntax error near unexpected token fi Nortekman Linux - Newbie 8 02-27-2009 04:48 PM
syntax error for unexpected token `(' Steve Spurr Linux - Newbie 6 09-22-2006 09:19 AM
syntax error near unexpected token `else' josedias Programming 3 09-11-2006 08:09 PM
syntax error near unexpected token ` mattyspatty Programming 8 05-07-2006 06:19 PM


All times are GMT -5. The time now is 11:12 AM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration