[help] Writing to /opt/local/var/log/install_setup.log ?
Bryan Blackburn
blb at macports.org
Fri May 2 17:47:09 PDT 2008
On May 2, 2008, at 5:36 PM, Bill Hernandez wrote:
> I am trying to write a running command log to : /opt/local/var/log/
> install_setup.log
> but doing either below :
>
> shell> $ sudo echo "${TS} $1" >> $BASH_CMD_LOG
> shell> $ sudo su -m root echo "${TS} $1" >> $BASH_CMD_LOG
>
> do not work...
>
This fails since sudo applies to the command, but redirection (>, >>,
and |) is done in your shell, hence that isn't run by sudo (in fact,
it's what is running sudo...).
...
>
> Anybody know how to write to the log using test_one() without having
> to alter file/dir permissions, or use any of the alternatives
> mentioned above...
>
If you definitely don't want to change permissions on the directory or
just the log file so you can write as your own user, one option would
be to use tee:
$ sudo port install mycoolport | sudo tee -a /opt/local/var/log/port.log
This will send the port output to your terminal and to the log file (-
a tells tee to append, not overwrite, just like >>). And since you're
running tee with sudo, it has the permission to write to that location.
Bryan
> TIA
>
> Bill Hernandez
> Plano, Texas
More information about the macports-users
mailing list