LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 10-23-2009, 05:33 AM   #1
chisunum
LQ Newbie
 
Registered: Oct 2009
Posts: 1

Rep: Reputation: 0
Post why is my shell script giving me - syntax error near unexpected token 'enterInfo()


#!
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
 
Old 10-23-2009, 06:38 AM   #2
fusion1275
Member
 
Registered: Jul 2007
Location: Knaphill, Surrey
Distribution: Linux Mint
Posts: 310

Rep: Reputation: 36
You can always start by defining what shell to use. I dont think
Quote:
#!
will work.

Just a good starting point.
 
Old 10-23-2009, 06:42 AM   #3
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
if you are using the bash shell, #! should be #!/bin/bash
 
Old 10-23-2009, 03:37 PM   #4
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 102Reputation: 102
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.
 
  


Reply

Tags
help, please, resolve


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

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

All times are GMT -5. The time now is 03:19 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