LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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, 10:13 AM   #1
chakka.lokesh
Member
 
Registered: Mar 2008
Distribution: Ubuntu
Posts: 245

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 01:48 AM. Reason: correcting normarl to normal in the title
 
Old 08-04-2014, 10:25 AM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,150

Rep: Reputation: 887Reputation: 887Reputation: 887Reputation: 887Reputation: 887Reputation: 887Reputation: 887
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, 10:46 AM   #3
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,239

Rep: Reputation: 1405Reputation: 1405Reputation: 1405Reputation: 1405Reputation: 1405Reputation: 1405Reputation: 1405Reputation: 1405Reputation: 1405Reputation: 1405
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, 01:46 AM   #4
chakka.lokesh
Member
 
Registered: Mar 2008
Distribution: Ubuntu
Posts: 245

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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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