how can i create new file in /var/log directory using python language in OSX leopard? i tried to do it using os.open function but i get "permission denied"
thanks in advance
how can i create new file in /var/log directory using python language in OSX leopard? i tried to do it using os.open function but i get "permission denied"
thanks in advance
It probably failed because /var/log has user set to root and group set to wheel. Try running your python code as root and it will probably work.
Only root can write in /var/log/
on Mac OS X...:
$ ls -ld /var/log
drwxr-xr-x 60 root wheel 2040 Oct 6 17:00 /var/log
Maybe consider using the syslog
module in the standard library...
You can create the log file as root and then change the owner to the user your script is run as
# touch /var/log/mylogfile
# chown myuser /var/log/mylogfile
where mylogfile is your logfile and myuser is the user the script will be run as
also look into logrotate