Files
webgui/plugins/dynamix/scripts/pre
Eric Schultz 30ca111094 initial commit
2015-10-24 10:17:28 -07:00

22 lines
404 B
Bash
Executable File

#!/bin/bash
# usage: pre <command>
# Executes <command>, wrapping it's output in <pre></pre> tags.
# Also redirects stderr to stdout, and generates syslog entry if <command> exit status > 0
# per WeeboTech (thanks!).
#
exec 2>&1
echo '<pre style="margin-top:-20px">'
eval "$@"
RC=$?
echo '</pre>'
if [ ${RC} -gt 0 ]
then logger -t$0 -puser.err <<-EOF
pre $@: exit status:${RC}
EOF
fi
exit ${RC}