LinuxQuestions.org
Visit the LQ Articles and Editorials section
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-08-2013, 09:24 AM   #1
dy20082250
Member
 
Registered: Oct 2013
Location: China
Distribution: Fefora 9
Posts: 52

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]then\
[tab]cp myapp $(INSTDIR) &&\
[tab]chmod a+x $(INSTDIR)/myapp &&\
[tab]chmod og-w $(INSTDIR)/myapp &&\
[tab]echo "Installed in $(INSTDIR)";\
[tab]else\
[tab]echo "Sorry,$(INSTDIR) does not exist" ;false ;\
fi

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
Member
 
Registered: Jun 2010
Location: Devon,UK
Distribution: Linux From Scratch, Slackware64,
Posts: 874

Rep: Reputation: 174Reputation: 174
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
Code:
INSTDIR=/tmp/LFS
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 ; \
fi
 
1 members found this post helpful.
  


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 `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 01:22 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