Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 07-05-2009, 11:59 AM   #1
LQ Newbie
Registered: Jul 2009
Posts: 1

Rep: Reputation: 0
syntax error near unexpected token "fi"

I'm having problems executing this script:
the "syntax error newar unexpected token "fi" comes up. I have tried all that I know. thanks in advance.

# START:./ $1 $2 $3
# $1=$1
# $2=$2
# $3=$3

# "Check number of command line arguments."
# "Three numbers not present print error message."
if [ $# -ne 3 ];
# echo "$0: Three numbers must be given"

# echo "Correct number of command line arguments entered."


if [ $1 -gt $2 ] && [ $1 -gt $3 ];
echo -e "\033[32m "The first number is the largest"

if [ $2 -gt $1 ] && [ $2 -gt $3 ];
echo "The second number is the largest"

if [ $3 -gt $1 ] && [ $3 -gt $2 ];
echo -e "\033[42m "The third number is biggest!"

echo -e "\033[0m Script execution complete"

Old 07-05-2009, 12:12 PM   #2
Senior Member
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,272

Rep: Reputation: 148Reputation: 148
Refer this
Old 07-05-2009, 12:20 PM   #3
LQ Guru
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
You missed then in the last if/then. done at the end of the script means nothing and gives error. Also check carefully the double quotes in the echo statements: they must be in pairs.
Old 07-05-2009, 01:00 PM   #4
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 469Reputation: 469Reputation: 469Reputation: 469Reputation: 469
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.


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
syntax error near unexpected token `set' `if ( $dirhome == "." ) set dirhome = `pwd dayanand patil Linux - General 6 01-21-2009 01:52 AM
syntax error unexpected token near "then" pclimmex Linux - Newbie 1 06-20-2008 10:51 PM
chmod: 1: Syntax error: "(" unexpected - what's this mean and how do I fix it? SeriesOne Linux - Newbie 6 02-22-2008 01:18 PM
Backup Script error "line 31: syntax error: unexpected end of file" eswanepoel General 7 12-07-2007 09:28 AM
syntax error near unexpected token `else' josedias Programming 3 09-11-2006 07:09 PM

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

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