[sudo-users] appending to a root owned file.
Galen Johnson
Galen.Johnson at sas.com
Mon Jan 10 12:02:07 EST 2005
You may want to edit your script to copy /etc/hosts to /tmp, modify the file in temp then copy it back to /etc using sudo...sudo doesn't do pipes or redirects...
=G=
-----Original Message-----
From: sudo-users-bounces at courtesan.com [mailto:sudo-users-bounces at courtesan.com] On Behalf Of DBSMITH at OhioHealth.com
Sent: Monday, January 10, 2005 10:54 AM
To: sudo-users at sudo.ws
Subject: [sudo-users] appending to a root owned file.
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?
thanks, derek
____________________________________________________________
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