[sudo-users] appending to /etc/hosts as a non root user using sudo
Paul M. Lambert
plambert at plambert.net
Thu Jan 6 19:18:55 EST 2005
dude somehost = /usr/bin/tee -a /etc/hosts
echo $dev"\t"$id"\t""# $loc" | sudo /usr/bin/tee -a /etc/hosts >
On Jan 6, 2005, at 1:17 PM, DBSMITH at OhioHealth.com wrote:
> I was looking in the archives and found some data related to what I
> to accomplish, but not quite.
> It told me to :
> % sudo sh -c 'echo foo >> /var/log/bar'
> With a sudoers entry like:
> dude somehost = /bin/sh -c /bin/echo foo >> /var/log/bar
> but what I want is to append to /etc/hosts using sudo from with a
> that holds variables.
> For example,
> sudo echo $dev"\t"$id"\t""#" $loc >> /etc/hosts
> but this is given me permission errors.
> so then I tried:
> sudo sh -c 'echo $dev"\t"$id"\t""#" $loc >> /etc/hosts'
> with the line in my sudoers file /usr/bin/sh -c
> I am running 1.6.6
> Any ideas?
> thank you
> Derek B. Smith
> OhioHealth IT
> UNIX / TSM / EDM Teams
> sudo-users mailing list <sudo-users at sudo.ws>
> For list information, options, or to unsubscribe, visit:
More information about the sudo-users