LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
 
Search this Thread
Old 11-15-2007, 04:25 PM   #1
powah
Member
 
Registered: Mar 2005
Distribution: FC, Gentoo
Posts: 276

Rep: Reputation: 30
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
 
Old 11-15-2007, 04:47 PM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,401

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Code:
v1=`/sbin/service snmpd start > /dev/null`
v2=`echo $v1|grep known_err`
if [[ $? -ne 0 ]]
then
    echo "New error"
fi
 
Old 11-15-2007, 10:17 PM   #3
powah
Member
 
Registered: Mar 2005
Distribution: FC, Gentoo
Posts: 276

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by chrism01 View Post
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
 
Old 11-16-2007, 06:08 AM   #4
powah
Member
 
Registered: Mar 2005
Distribution: FC, Gentoo
Posts: 276

Original Poster
Rep: Reputation: 30
/sbin/service snmpd start 2>&1 >/dev/null | grep -v "WARNING: initlog is deprecated and will be removed in a future release" >&2
 
Old 11-17-2007, 08:34 PM   #5
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,401

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
stderr instead of stdout; ah well
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Suppress a particular gcc compiler warning? lamar_air Programming 7 10-09-2011 02:04 AM
How to suppress particular warning message? hottdogg Programming 3 03-02-2007 01:15 AM
why warning message is appear? eye Red Hat 3 10-22-2003 09:14 AM
suppress warning messages h/w Programming 2 10-07-2003 02:56 PM
Boot Warning Message enlight1 Linux - General 6 06-18-2003 01:15 AM


All times are GMT -5. The time now is 09:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration