LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   why always “syntax error near unexpected token 'fi'” (http://www.linuxquestions.org/questions/linux-newbie-8/why-always-%93syntax-error-near-unexpected-token-fi%94-4175480025/)

dy20082250 10-08-2013 10:24 AM

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

Keith Hedger 10-08-2013 10:44 AM

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



All times are GMT -5. The time now is 08:09 AM.