LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 08-04-2014, 09:13 AM   #1
chakka.lokesh
Member
 
Registered: Mar 2008
Distribution: Ubuntu
Posts: 243

Rep: Reputation: 32
problem with adding new extension in mime.types file using Makefile as normal user


Code:
user@machine:~$ cat Makefile 
install:
	@grep "application/x-abcd" /etc/mime.types >> /dev/null
	if [ "$?" -eq 1 ]
	then
		sudo echo "application/x-abcd		abcd"	>> /etc/mime.types;
	fi

user@machine:~$ make
make: *** [install] Error 1
i am running make as normal user. I want to append the line
Quote:
application/x-abcd abcd
only if it is not already existing.


can some one please help me in getting rid of that error ?

Last edited by chakka.lokesh; 08-05-2014 at 12:48 AM. Reason: correcting normarl to normal in the title
 
Old 08-04-2014, 09:25 AM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,110

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
Quote:
Originally Posted by chakka.lokesh View Post
Code:
user@machine:~$ cat Makefile 
install:
	@grep "application/x-abcd" /etc/mime.types >> /dev/null
	if [ "$?" -eq 1 ]
	then
		sudo echo "application/x-abcd		abcd"	>> /etc/mime.types;
	fi

user@machine:~$ make
make: *** [install] Error 1
i am running make as normal user. I want to append the line

only if it is not already existing.


can some one please help me in getting rid of that error ?
maybe the quotes are forcing the interpreter to see $? as a string rather than a number ?
 
Old 08-04-2014, 09:46 AM   #3
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Arch
Posts: 3,131

Rep: Reputation: 1317Reputation: 1317Reputation: 1317Reputation: 1317Reputation: 1317Reputation: 1317Reputation: 1317Reputation: 1317Reputation: 1317Reputation: 1317
Every line of a make recipe is a separate shell, so you have to put everything together on one logical line (backslashes allow spreading it over several physical lines). Also, the sudo only applies to the echo not the redirection so it won't work.

Code:
install:
	@grep -Fq "application/x-abcd" /etc/mime.types || \
	  echo "application/x-abcd		abcd" | sudo tee -a /etc/mime.types > /dev/null
 
1 members found this post helpful.
Old 08-05-2014, 12:46 AM   #4
chakka.lokesh
Member
 
Registered: Mar 2008
Distribution: Ubuntu
Posts: 243

Original Poster
Rep: Reputation: 32
ntubski,

thanks. your post helped me.
 
  


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
[SOLVED] 'file -bi' and custom mime types ewsmith Linux - General 3 03-02-2011 08:31 PM
Problem with MIME types? jnojr Linux - General 2 02-11-2009 11:07 AM
mime-types/default actions for new file extensions? lumix Linux - Newbie 1 07-09-2008 03:31 PM
Get file icon from extension, file type, or mime-type Guitarist88 Programming 3 04-21-2008 10:58 AM
Squid problem -- how to define certain MIME-types Isotonik Linux - General 0 11-23-2005 02:26 AM


All times are GMT -5. The time now is 12:03 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration