diff --git a/Makefile b/Makefile index b9fda66..5500181 100644 --- a/Makefile +++ b/Makefile @@ -71,6 +71,7 @@ install: scripts/sc scripts/scinit scripts/sc_install_defaults target/sc.jar tar install -m 555 -o qsys scripts/sc ${INSTALL_ROOT}/QOpenSys/pkgs/bin/ install -m 555 -o qsys scripts/scinit ${INSTALL_ROOT}/QOpenSys/pkgs/bin/ install -m 555 -o qsys scripts/scedit ${INSTALL_ROOT}/QOpenSys/pkgs/bin/ + install -m 555 -o qsys scripts/sctail ${INSTALL_ROOT}/QOpenSys/pkgs/bin/ install -m 555 -o qsys scripts/scopenports ${INSTALL_ROOT}/QOpenSys/pkgs/bin/ install -m 555 -o qsys scripts/sc_install_defaults ${INSTALL_ROOT}/QOpenSys/pkgs/bin/ install -m 444 -o qsys target/sc.jar ${INSTALL_ROOT}/QOpenSys/pkgs/lib/sc/sc.jar diff --git a/scripts/sctail b/scripts/sctail new file mode 100755 index 0000000..1c3e2c5 --- /dev/null +++ b/scripts/sctail @@ -0,0 +1,92 @@ +#!/QOpenSys/pkgs/bin/bash + +if [[ "$LC_ALL" != *UTF-8* ]]; then + # LC_ALL is not set. Set it to EN_US.UTF-8 if present + if [ -e /usr/lib/nls/loc/EN_US.UTF-8 ]; then + export LC_ALL=EN_US.UTF-8 + else + # EN_US.UTF-8 is not present. Look for installed UTF-8 locale + INSTALLEDUTF8LOCALE=$(ls -b /usr/lib/nls/loc | grep -E '.UTF-8$' | tail -n 1) + if [[ "" = "$INSTALLEDUTF8LOCALE" ]]; then + >&2 echo "WARNING: Cannot find a UTF-8 locale installed on this system." + else + export LC_ALL=$INSTALLEDUTF8LOCALE + fi + fi +fi + +if (($# == 0)); then + echo "usage: sctail [tail OPTION]... " + exit 0 +fi + +HELP_MSG=NO + +# Set the default arguments for tail +TAIL_ARGS="" + +# Initialize variable for service name +SERVICE="" + +# Declare an array to hold the arguments and their values +declare -a ARGS=() + +# Loop through the command line arguments +while [[ $# -gt 0 ]]; do + key="$1" + case $key in + -c|--bytes|-n|--lines|-s|--sleep-interval|--pid|--max-unchanged-stats) + # If the argument has a value, add it to the array + if [[ $# -gt 1 && "$2" != -* ]]; then + ARGS+=("$1 $2") + shift + else + ARGS+=("$1") + fi + ;; + -f|--follow|-F|--retry|-q|--quiet|--silent|-v|--verbose|-z|--zero-terminated|--version) + ARGS+=("$1") + ;; + --help) + HELP_MSG=YES + shift # past argument with no value + ;; + -*|--*) + echo "sctail: invalid option -- '$1'" + echo "usage: sctail [OPTION]... " + echo "Try 'sctail --help' for more information." + exit 1 + ;; + *) + + # If the argument doesn't start with a dash, set it as the SERVICE value + SERVICE="$1" + ;; + esac + shift +done + +if [[ $HELP_MSG == YES ]]; then + echo "sctail usage: sctail [tail OPTION]...