aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2015-03-18 09:50:14 +1300
committerTom Ryder <tom@sanctum.geek.nz>2015-03-18 09:50:14 +1300
commit5e33553a2312670306ff17466a3bf75f6de82efb (patch)
treeb5fb2e4bc3b92b54d79c39aafdca3e4b19f5a3f2
parentInclude running time in output of check (diff)
downloadnscaw-5e33553a2312670306ff17466a3bf75f6de82efb.tar.gz
nscaw-5e33553a2312670306ff17466a3bf75f6de82efb.zip
More reliable usernaming
-rwxr-xr-xnscaw9
1 files 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
# <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"