Register a domain and help support LQ
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 10-08-2013, 09:24 AM   #1
Registered: Oct 2013
Location: China
Distribution: Fefora 9
Posts: 63

Rep: Reputation: Disabled
Question why always “syntax error near unexpected token 'fi'”

I am a new to Linux .today I'm learning the makefile My script as following:
install: myapp
[tab]@if [ -d $(INSTDIR) ];\
[tab]cp myapp $(INSTDIR) &&\
[tab]chmod a+x $(INSTDIR)/myapp &&\
[tab]chmod og-w $(INSTDIR)/myapp &&\
[tab]echo "Installed in $(INSTDIR)";\
[tab]echo "Sorry,$(INSTDIR) does not exist" ;false ;\

when i run the "make -f makefile install"

/bin/sh:-c:line 8:syntax error near unexpected token 'fi'
/bin/sh:-c:line 8:'fi'
I have changed the makefile many times with many ways,but I can find out a solution.Please help me
Old 10-08-2013, 09:44 AM   #2
Keith Hedger
Senior Member
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 1,728

Rep: Reputation: 388Reputation: 388Reputation: 388Reputation: 388
A couple of things enclose code in "[code] [\code]" to make it easier to read ( without the quotes ).

add a space before each of the "\" like so
install: myapp
	@if [ -d $(INSTDIR) ]; \
	then \
	cp myapp $(INSTDIR) && \
	chmod a+x $(INSTDIR)/myapp && \
	chmod og-w $(INSTDIR)/myapp && \
	echo "Installed in $(INSTDIR)"; \
	else \
	echo "Sorry,$(INSTDIR) does not exist" ;false ; \
1 members found this post helpful.


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 `fi' thomas2004ch Programming 11 08-04-2011 07:53 AM
[SOLVED] Syntax error near unexpected token `in' Sirnot1 Linux - Newbie 2 06-28-2011 07:45 PM
syntax error near unexpected token `else' nav007_2000 Programming 7 02-11-2011 09:14 AM
syntax error near unexpected token Aigarzs Linux - Newbie 3 01-12-2008 03:39 PM
syntax error near unexpected token deskjockey39 Linux - General 2 01-16-2007 08:47 AM

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