jhablfs

Ag Hatzim zkom.xl at gmail.com
Sun Jan 29 18:01:52 PST 2006


Hi all.

Manuel,just a small addition to Richard's remarks,but please
ignore it,if you had already noticed that.

Commands that using cat with sudo,to redirect the output to 
certain files that users have no write access,will fail. 

Eg. fcron.
#-------------------------------# 
(~/jhablfs)sudo cat >> /etc/syslog.conf << "EOF"
# Begin fcron addition to /etc/syslog.conf

cron.* -/var/log/cron.log

# End fcron addition
EOF
zsh: permission denied: /etc/syslog.conf
#-------------------------------# 

Since the shell is doing the redirection (man bash -REDIRECTION),*before*
the command is executed ,sudo can not see the redirection,so a new shell
is needed for sudo to execute the actual command.

Like so,the previous command should be something like this.
#-------------------------------# 
(~/jhablfs)sudo sh -c "cat >> /etc/syslog.conf << "EOF"
# Begin fcron addition to /etc/syslog.conf

cron.* -/var/log/cron.log

# End fcron addition
EOF"
#-------------------------------# 

Regards.

Ag.



More information about the alfs-discuss mailing list