You are not logged in.
I noticed the colors on stat_* functions from /etc/rc.d/functions only works when the root user is running a command (or when a normal user runs with sudo). How to get the colors for my user when some other bash script includes and uses these functions?
For those which are not familiar with the stat_* functions, they're responsable for these messages:
$ /etc/rc.d/httpd restart
:: Restarting Apache Web Server [DONE]
P.S. I noticed the functions script checks the $USECOLOR variable, so I already tried setting USECOLOR=yes to my .bashrc with no success.
Last edited by falmp (2012-01-20 11:30:44)
Offline
Can you post your script? Are you sourcing the functions?
# Exit current shell if user is not root
need_root() {
(( EUID )) && printf 'You need to be root.\n' && exit 1
}
# Quit script if it's not running by root
# This can be disabled in scripts sourcing functions by setting NEED_ROOT=0
# A local call to need_root can be done to ensure part of script need root privilege
(( ${NEED_ROOT:-0} == 1 )) && need_root
Offline
Sure.
#!/bin/bash
. /etc/rc.d/functions
case "$1" in
start)
ACTIVITY=uol
if [ "$#" -eq 2 ]; then
ACTIVITY=$2
fi
stat_busy "Starting hamster with activity $ACTIVITY";
hamster-cli start $ACTIVITY
stat_done
;;
stop)
stat_busy "Stopping hamster";
hamster-cli stop
stat_done
;;
*)
$HOME/.bin/hamster-day $1
esac
Last edited by falmp (2012-01-19 20:29:31)
Offline
Have you tried setting' NEED_ROOT=0'?
Offline
I didn't notice the NEED_ROOT part on your first post. I tried it now though with no different results (my hamster script works, I'm just not getting colored output).
Offline
'USECOLOR="yes"' works for me.
NEED_ROOT=0
USECOLOR="yes"
. /etc/rc.d/functions
Last edited by karol (2012-01-19 23:02:03)
Offline
Sorry, indeed it works. Thank you! I was missing an "export" on my USECOLOR=yes at .bashrc.
Last edited by falmp (2012-01-20 00:22:11)
Offline
Please remember to mark the thread as solved :-)
Offline
Done.
Offline