echo bug?

Siggy Brentrup ubuntu at psycho.i21k.de
Sat Sep 12 03:14:15 UTC 2009


On Fri, Sep 11, 2009 at 22:53 -0400, Fred Roller wrote:
> sudo echo "deb http://ppa.launchpad.net/gwibber-team/ubuntu hardy main" /etc/apt/sources.list.d/gwibber.list
> 
> 
> I believe your line is being read as *two* commands.  one under sudo and one under user.  try:

Yeah, that's the problem.
 
> sudo echo "deb http://ppa.launchpad.net/gwibber-team/ubuntu hardy main"  >> /etc/apt/sources.list.d/gwibber.list
> 
> 
> which will append your echo to the end of the file.

Nope, this won't work either, reason: as written redirection is
accomplished by the shell, i.e. without root permission.

The above command is too long for an example, try these:

% sudo rm sample  # make sure file doesn't exist
rm: cannot remove `sample': No such file or directory
% sudo touch sample  # create file owned by root
% sudo echo "will fail" >>sample
zsh: permission denied: sample
% sudo echo "will not work either >>sample"
will not work either >>sample
% sudo sh -c "echo \"will work\" >>sample"
% cat sample
will work
% 

HTH
  Siggy (wondering why this thread is that long)
-- 
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org+
|34 days until|bsb-at-psycho-dot-informationsanarchistik-dot-de|
|www.Ubucon.de|or:                bsb-at-psycho-dot-i21k-dot-de|
+-------> ceterum censeo javascriptum esse restrictam <--------+




More information about the ubuntu-users mailing list