diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2015-03-18 09:50:14 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2015-03-18 09:50:14 +1300 |
commit | 5e33553a2312670306ff17466a3bf75f6de82efb (patch) | |
tree | b5fb2e4bc3b92b54d79c39aafdca3e4b19f5a3f2 | |
parent | Include running time in output of check (diff) | |
download | nscaw-5e33553a2312670306ff17466a3bf75f6de82efb.tar.gz nscaw-5e33553a2312670306ff17466a3bf75f6de82efb.zip |
More reliable usernaming
-rwxr-xr-x | nscaw | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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 # <http://mywiki.wooledge.org/BashFAQ/032> 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" |