SPUG: Inspired, broken.

Atom Powers atomic at wyrdtech.com
Wed Feb 9 14:00:53 PST 2005


Yes, that makes sense. Thank you.
Incidently this is irrelevant, since the command will be run as part of a cron 
job which is run as mailman.

--
Perfection is just a word I use occasionally with mustard.
--Atom Powers--

Gardner Cohen wrote:
> Atom Powers wrote:
> 
>> Is sudo dropping privileges back to 'apowers' when it sees the '>'?
> 
> 
> No. sudo has nothing to do with the ">".
> 
> the shell sees "command" redirect file
> 
> command happens to be sudo something, but the shell is running as you 
> and does the redirect as you.
> 
> There are several ugly and not so ugly workarounds.  One is:
> 
> yourcommand | sudo dd of=thatoutfile.txt
> 
> (assuming yourcommand didn't need to run as root)
> 
> another is to investigate sh -c "shell command with special characters".
> 
> e.g.
> 
> sudo /bin/sh -c "yourcommand > yourfile.txt"
> 
> which will make the redirection happen in a shell running as root.
> 
> Ah too late, someone already said mostly the same thing.
> 


More information about the spug-list mailing list