LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   suppress known warning message (https://www.linuxquestions.org/questions/programming-9/suppress-known-warning-message-599939/)

powah 11-15-2007 04:25 PM

suppress known warning message
 
When snmpd is started, a warning will appear.
How to suppress this known warning message, i.e. other warning message will still appear.
# /sbin/service snmpd start > /dev/null
WARNING: initlog is deprecated and will be removed in a future release

If I do this, I am afraid all other warning messages (if any in the future) will be suppressed:
#/sbin/service snmpd start >& /dev/null

chrism01 11-15-2007 04:47 PM

Code:

v1=`/sbin/service snmpd start > /dev/null`
v2=`echo $v1|grep known_err`
if [[ $? -ne 0 ]]
then
    echo "New error"
fi


powah 11-15-2007 10:17 PM

Quote:

Originally Posted by chrism01 (Post 2960299)
Code:

v1=`/sbin/service snmpd start > /dev/null`
v2=`echo $v1|grep known_err`
if [[ $? -ne 0 ]]
then
    echo "New error"
fi


Thanks, but it does not work.
I add some echo statements.

Code:

known_err="WARNING"
v1=`/sbin/service snmpd start > /dev/null`
v2=`echo $v1|grep known_err`
v3=`echo $v1|grep $known_err`
echo "v1 $v1 v2 $v2 v3 $v3"
v4=`echo $v1|grep $known_err`
if [[ $? -ne 0 ]]
then
    echo "New error"
fi

# sh suppressWarn.sh
WARNING: initlog is deprecated and will be removed in a future release
v1 v2 v3
New error

powah 11-16-2007 06:08 AM

/sbin/service snmpd start 2>&1 >/dev/null | grep -v "WARNING: initlog is deprecated and will be removed in a future release" >&2

chrism01 11-17-2007 08:34 PM

stderr instead of stdout; ah well


All times are GMT -5. The time now is 04:54 PM.