LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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
 
LinkBack Search this Thread
Old 11-14-2005, 09:00 AM   #1
sateeshgalla
LQ Newbie
 
Registered: Apr 2005
Location: Bangalore
Posts: 16

Rep: Reputation: 0
makefile, shell commands error


Hi,
this is sateesh. I wrote a make file. it contains the following code.

.PHONY: clean
clean:
<tab> @echo "cleaning files"
<tab> if [ -f dri_frame.o ]; then \
<tab> echo "file found" \
<tab> fi

when i execute is

"make clean" its giving the following errors.

[root@localhost practice]# make clean
cleaning files
if [ -f dri_frame.o ]; then \
echo "file found" \
fi
/bin/sh: -c: line 1: syntax error: unexpected end of file
make: *** [clean] Error 2
[root@localhost practice]#

what is the error?

does anyone has a solution?

Thanks in advance.

Regards
Sateesh

Last edited by sateeshgalla; 11-14-2005 at 09:02 AM.
 
Old 11-14-2005, 10:29 AM   #2
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,282

Rep: Reputation: 66
try add a semi colon char ' ; ' at the end of your command lines :

Code:
.PHONY: clean
clean:
        @echo "cleaning files"
        if [ -f dri_frame.o ]; then \
        echo "file found"; \
        fi;
 
Old 11-14-2005, 10:33 AM   #3
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 5,766
Blog Entries: 4

Rep: Reputation: 697Reputation: 697Reputation: 697Reputation: 697Reputation: 697Reputation: 697
Why even have all the extra characters?

Code:
.PHONY: clean
clean:
        @echo "cleaning files"
        if [ -f dri_frame.o ]
        then echo "file found"
        fi
You don't need the semi-colon and slashes for line continuation if it can run on separate lines as it can for if-then. The ; syntax is usually used when people want to put the whole conditional on one line. Since you're doing three lines anyway just clean it up the way it ought to be without the superfluous characters.
 
Old 11-14-2005, 10:35 AM   #4
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
You also might want an else for when the file it isn't found.
Code:
.PHONY: clean

clean:
	@echo "cleaning files"

	if [ -f dri_frame.o ]; then \
	clear; echo "The file was found" ; \
	else \
	clear; echo "The file was not found" ; \
	fi
You also might want look into some kind of exit if it isn't found.
 
Old 11-14-2005, 10:57 PM   #5
sateeshgalla
LQ Newbie
 
Registered: Apr 2005
Location: Bangalore
Posts: 16

Original Poster
Rep: Reputation: 0
sorry, it did not work

hi,
Thanks very much.
its got solved.
Semicolon should be added at the end for every command line.

regards,
sateesh

Last edited by sateeshgalla; 11-14-2005 at 11:15 PM.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
shell scripting and makefile sandy_linux Linux - Software 1 09-05-2005 12:33 PM
Linux shell command for makefile.in to create a text file and write to it alix123 Programming 8 01-07-2005 08:18 AM
shell scripts in Makefile? SheldonPlankton Linux - General 4 08-16-2004 04:40 AM
Shell Script and makefile thomasmathew Programming 11 12-23-2003 03:08 PM
shell commands! krishlinux General 1 10-05-2003 04:47 AM


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