I'm running an embedded Linux (Dreadnaught), and I'd like to be able to manually enter a line into the syslog as the user login, and have the result of other commands stored in the syslog. e.g.:
echo ======== Setting chat and Options for Insys >>/var/log/messages cat /etc/ppp/options >> /var/log/messages
Syslog is initiated in /etc/inittab:
::respawn:/sbin/syslogd -n -s 200 -b 2 -S -m0
I have some alias' to perform common tasks, and I'd like syslog to be updated when they are run:
alias Insys='echo =================== Setting chat and Options for Insys >> /var/log/messages; cp /var/config/tw_con_Insys.lge /var/config/tw_con.lge; cp /etc/ppp/peers/tw_options_Insys /etc/ppp/peers/tw_options; con; echo =================== Complete >> /var/log/messages' alias setup='echo =================== options ===================; echo ""; echo ""; cat /etc/ppp/options; echo ""; echo ""; echo =================== chat ===================; echo ""; echo ""; cat /var/config/tw_con.lge; echo ""; echo ============================================;'
The setup command writes to the terminal, I would like it to write to the syslog instead, i.e. setup>>/var/log/messages.
The problem is that /var/log/messages is owned by root, not user. I can manually run
su -c 'chmod 777 /var/log/messages'
, it prompts me for the root pwd, then after this I can run my shortcuts and they work. However, each time the log rolls over to messages.0 and a new messages is created, I've lost the privs and have to run it again.
I tried to create an alias for this chmod so I can run it before I run my custom scripts:
alias userlog='su -c ''chmod 777 /var/log/messages'''
The alias is accepted, but doesn't run.
[user@Dreadnaught_TEP1 etc]$ userlog su: unknown user 777
Thanks for your help!