Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > sudo cat permission denied?!

sudo cat permission denied?!
Thread Tools
Mac Enthusiast
Join Date: Aug 2001
Location: Durango CO
Status: Offline
Reply With Quote
Dec 11, 2005, 02:19 PM
 
so this works

Code:
su cat >> /etc/hosts
and this works

Code:
sudo pico /etc/hosts
but this throws a permission denied?!

Code:
sudo cat >> /etc/hosts
What gives?
The Bitcastle
graphic design, web development, hosting
     
mania  (op)
Mac Enthusiast
Join Date: Aug 2001
Location: Durango CO
Status: Offline
Reply With Quote
Dec 11, 2005, 03:04 PM
 
I will add that what I am trying to do is add a line to the end of the file using a script, so going into su and/or pico isn't what i want. if there is another way that works better let me know and many thanks.
The Bitcastle
graphic design, web development, hosting
     
Grizzled Veteran
Join Date: Apr 2002
Location: case.edu
Status: Offline
Reply With Quote
Dec 11, 2005, 06:34 PM
 
Did you mean that
Code:
sudo cat >> /etc/hosts
didn't work?

If so, that's because the redirection is handled by the shell, and the shell's privileges are not altered by sudo. You can get around this problem by performing the redirection 'inside' the sudo process:
Code:
sudo sh -c 'cat >> /etc/hosts'

pb 1440x960 | 1.67, 1.5, 128, 80 | leopard
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 08:04 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2