From 5e33553a2312670306ff17466a3bf75f6de82efb Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 18 Mar 2015 09:50:14 +1300 Subject: More reliable usernaming --- nscaw | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/nscaw b/nscaw index 591b171..d9737e5 100755 --- a/nscaw +++ b/nscaw @@ -49,6 +49,9 @@ shift 2 # it can be overridden with the value of NSCAW_HOSTNAME if defined hostname=${NSCAW_HOSTNAME:-$(hostname -s)} +# Figure out our username +username=$(whoami) + # Attempt to run command within a time wrapper # exec 3>&1 4>&2 @@ -65,17 +68,17 @@ case $ret in 0) code=0 # OK message=$(printf '%s: `%s` ran with no errors as user %s: %s' \ - "$self" "$*" "$USER" "$time") + "$self" "$*" "$username" "$time") ;; 127) code=3 # UNKNOWN message=$(printf '%s: `%s` could not be found as user %s with PATH=%s' \ - "$self" "$1" "$USER" "$PATH") + "$self" "$1" "$username" "$PATH") ;; *) code=2 # CRITICAL message=$(printf '%s: `%s` ran with errors as user %s: %s' \ - "$self" "$*" "$USER" "$time") + "$self" "$*" "$username" "$time") ;; esac printf '%s\n' "$message" -- cgit v1.2.3