diff options
author | Hansen, Tony (th1395) <th1395@att.com> | 2021-10-27 00:32:01 +0000 |
---|---|---|
committer | Hansen, Tony (th1395) <th1395@att.com> | 2021-11-02 00:30:01 +0000 |
commit | 2861c7f08cba6c0cbd5af39aece1ab6c8bc3e368 (patch) | |
tree | 1beb52e5587af7ed165ebc88e22eab99d755b9d0 /snmptrap/snmptrapd.sh | |
parent | 7d0c9432f13d83ed19cc07d3a61cc528b3942822 (diff) |
send stdout logging to stdout in addition to log files
Change-Id: Icad02afe29e28eef72cc36dd82f0a64810ce9500
Signed-off-by: Hansen, Tony (th1395) <th1395@att.com>
Issue-ID: DCAEGEN2-2957
Signed-off-by: Hansen, Tony (th1395) <th1395@att.com>
Diffstat (limited to 'snmptrap/snmptrapd.sh')
-rwxr-xr-x | snmptrap/snmptrapd.sh | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/snmptrap/snmptrapd.sh b/snmptrap/snmptrapd.sh index a10e049..717f660 100755 --- a/snmptrap/snmptrapd.sh +++ b/snmptrap/snmptrapd.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash +# -*- indent-tabs-mode: nil -*- # vi: set expandtab: # # ============LICENSE_START======================================================= -# Copyright (c) 2017-2020 AT&T Intellectual Property. All rights reserved. +# Copyright (c) 2017-2021 AT&T Intellectual Property. All rights reserved. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -104,7 +105,7 @@ exec_cmd=$3 then mv -f ${stdout_fd} ${stdout_fd}.bak fi - ${exec_cmd} >> ${base_dir}/logs/${process_name}.out 2>&1 & + ${exec_cmd} 2>&1 | tee -a ${base_dir}/logs/${process_name}.out & g_return=$? echo $! > ${pid_file} else @@ -115,7 +116,7 @@ exec_cmd=$3 log_msg "${process_name} already running - PID ${pid}" else log_msg "PID file present, but no corresponding process. Starting ${process_name}" - ${exec_cmd} >> ${base_dir}/logs/${process_name}.out 2>&1 & + ${exec_cmd} 2>&1 | tee -a ${base_dir}/logs/${process_name}.out & g_return=$? echo $! > ${pid_file} fi @@ -303,23 +304,23 @@ reload_cfg() # # # # # # # # # # # # # # # version() { -exit_swt=$1 + exit_swt=$1 -version_fd=${base_dir}/etc/version.dat -if [ -f ${version_fd} ] -then - version_string=`cat ${version_fd}` - log_msg "${version_string}" - ec=0 -else - log_msg "ERROR: unable to determine version" - ec=1 -fi + version_fd=${base_dir}/etc/version.dat + if [ -f ${version_fd} ] + then + version_string=`cat ${version_fd}` + log_msg "${version_string}" + ec=0 + else + log_msg "ERROR: unable to determine version" + ec=1 + fi -if [ "${exit_swt}" == "${exit_after}" ] -then - exit ${ec} -fi + if [ "${exit_swt}" = "${exit_after}" ] + then + exit ${ec} + fi } |