LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 07-05-2009, 11:59 AM   #1
phillip58
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.


#!/bin/bash
#
# START:./numbers.sh $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 ];
then
# echo "$0: Three numbers must be given"

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

fi

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

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

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

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

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

Rep: Reputation: 131Reputation: 131
Refer this
http://www.freeos.com/guides/lsst/ch03sec03.html
 
Old 07-05-2009, 12:20 PM   #3
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,458

Rep: Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941
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
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Lubuntu
Posts: 19,174
Blog Entries: 4

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


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
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 01:52 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
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration