From: Kevin the Drummer on
Chris Davies <chris-usenet(a)roaima.co.uk> wrote:
> Kevin the Drummer <nobody(a)cosgroves.us> wrote:
> > Say, I've been wanting to know how to get sudo to work with redirection.
> > By that I mean that I need root permission to write into the redirection
> > target.
>
> Consider:
> some_command > some_file
>
> The "> some_file" happens before "some_command" is run. So when you try
> this with sudo:
> sudo some_command > some_file
>
> The "> some_file" happens as the invoking user, not as the sudo target
> user. (But you know this, right?)
>
> So, in order to get the "> some_file" to happen as the sudo target user,
> you need to include that in the sudo command. The only way to get that
> to happen is to have sudo execute a shell. So you get this:
> sudo sh -c "some_command > some_file"
>
> I'm sure you can create variations on that theme for tcsh.
> Chris

I should have thought to spawn a shell to run a command with output
and/or error redirection. Perfect. Thanks!

--
PLEASE post a SUMMARY of the answer(s) to your question(s)!
Unless otherwise noted, the statements herein reflect my personal
opinions and not those of any organization with which I may be affiliated.