Gentoo Archives: gentoo-user

From: Neil Bothwick <neil@××××××××××.uk>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] sudo echo cannot write to /etc/ files ?
Date: Wed, 06 Jul 2005 15:36:06
Message-Id: 20050706162607.08bed5f1@hactar.digimed.co.uk
In Reply to: Re: [gentoo-user] sudo echo cannot write to /etc/ files ? by David Morgan
1 On Wed, 6 Jul 2005 16:12:18 +0100, David Morgan wrote:
2
3 > Nope, I don't think you can do it with sudo since bash uses whitespace
4 > as a separator, so if you do sudo "echo foo >> bar", it'll look for a
5 > single command "echo foo >> bar", which is not what you want - you want
6 > a command echo with argument foo, and then redirect the output to bar
7 > (the double quotes prevent bash from evaluating the whitespace or the
8 > >>).
9
10 You could do it with a shell script
11
12 #!/bin/sh
13 #Call this /usr/local/bin/suecho
14 echo "$1" >>$2
15
16 Add /usr/local/bin/suecho to /etc/sudoers and you can do
17
18 sudo suecho "media-video/xine-ui ~x86" /etc/portage/package.keywords
19
20
21 --
22 Neil Bothwick
23
24 Software: (n.) That which hardware manufacturers can blame for physical
25 failures.