[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


sudoers:

dude	somehost = /usr/bin/tee -a /etc/hosts

script:

echo $dev"\t"$id"\t""# $loc" | sudo /usr/bin/tee -a /etc/hosts > 
/dev/null

Good luck!

--plambert

On Jan 6, 2005, at 1:17 PM, DBSMITH at OhioHealth.com wrote:

> All,
>
> I was looking in the archives and found some data related to what I 
> want
> 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 
> script
> that holds variables.
> For example,
>
> dev=172.25.123.123
> loc=ISF
> id=prt207
>
> 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:
> http://www.sudo.ws/mailman/listinfo/sudo-users




More information about the sudo-users mailing list