[Linux-disciples] sudo echo
Chung-chieh Shan
ccshan at post.harvard.edu
Sun Jun 12 18:25:42 EDT 2005
On 2005-06-12T18:07:48-0400, Stephen R Laniel wrote:
> Because of some subshell business, I'm sure, this never
> seems to work:
>
> sudo echo foo > /proc/something
The problem is that this command means "redirect the output of running
'echo foo' as root to /proc/something", not "redirect the output of
running 'echo foo' to /proc/something as root". After all, sudo is just
a regular program, and your shell handles both redirecting output and
running sudo.
For "sudo ... < file", you could say "sudo cat file | ..." instead.
For "sudo ... > file" as above, you could say "... | sudo act file"
given a script "act":
#!/bin/sh
exec cat >"$1"
This should work even when "file" contains funny characters.
If we don't have to worry about funny characters, then
sudo sh -c "echo foo > file"
suffices.
--
Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig
Mothers are the necessity of invention. --Bill Watterson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.bostoncoop.net/pipermail/linux-disciples/attachments/20050612/ac3d30c6/attachment.pgp
More information about the Linux-disciples
mailing list