LinuxQuestions.org
Register a domain and help support LQ
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 04-06-2007, 04:16 AM   #1
yixuan178
LQ Newbie
 
Registered: Apr 2007
Posts: 3

Rep: Reputation: 0
How to ignore messages from printk information?


Hello everyone,
Recently, I wrote an application, in this application, I call system() function, like:
+-+-+-+-+-+-+-+-+-+
system("modprobe ipmi_si 2>/dev/null");
+-+-+-+-+-+-+-+-+-+
But unfortunately, there will display some of messages like:
+-+-+-+-+-+-+-+-+-+-+-+-+
ipmi_si: Trying 'kcs' at I/O port 0xca2
...
+-+-+-+-+-+-+-+-+-+-+-+-+
It may cause my application chaos in screen when application run in character console.
So I want to ignore these messages.

First, I add a line in /etc/sysctl.conf like 'kernel.printk = 0' (actually I don't know how to set it, I just guess it.)
It seems ok, when I reload this file (sysctl -p), and run my application again, no warning message again.

However, I don't think this is a good idea for me, because I just want to ignore these messages when console run my application.
If I set variable in /etc/sysctl.conf, it will impact all of application. right?

So do you have any suggestion about this issue? What can I do with my application to ignore warning messages from kernel?
Can this issue solve in my application with some code?
Any suggestion will be appreciation!

Thanks in advance!!
yixuan
 
Old 04-06-2007, 05:35 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
The message you see is (I guess) the info that ipmi_si sends to stdout. Your system call already redirects stderr (if I understand your code), so you have to add stdout to it.

On the commandline, the command would look something like
Code:
ipmi_si >/dev/NULL 2>&1
Not 100% sure about exact syntax but the trick is to redirect stderr to stdout and redirect stdout to /dev/null.
 
Old 04-06-2007, 06:36 AM   #3
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,746

Rep: Reputation: 458Reputation: 458Reputation: 458Reputation: 458Reputation: 458
&> /dev/null my also be used.
 
Old 04-09-2007, 01:55 AM   #4
yixuan178
LQ Newbie
 
Registered: Apr 2007
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Wim Sturkenboom
The message you see is (I guess) the info that ipmi_si sends to stdout. Your system call already redirects stderr (if I understand your code), so you have to add stdout to it.

On the commandline, the command would look something like
Code:
ipmi_si >/dev/NULL 2>&1
Not 100% sure about exact syntax but the trick is to redirect stderr to stdout and redirect stdout to /dev/null.
Hello,
Thanks for your help!
I just execute this command in shell console.
modprobe impi_si >/dev/null 2>&1
and modprobe ipmi_si &>/dev/null

There have 5 messages:
ipmi_si: Trying "kcs" at I/O port 0xca2
ipmi_si: Trying "smic" at I/O port 0xca9
ipmi_si: Trying "bt" at I/O port 0xe4
ipmi_si: Unable to find any System Interface(s)
FATAL: Error inserting ipmi_si(/lib...): No such device

When I used >/dev/null, it just only ignore the last message.

...
Can I have another way to ignore these messages?

Thanks a lot!
 
Old 04-09-2007, 06:15 AM   #5
yixuan178
LQ Newbie
 
Registered: Apr 2007
Posts: 3

Original Poster
Rep: Reputation: 0
However, now, I find a way to solve my problem.
system("sysctl -w kernel.printk='4 4 1 7'");

Maybe it is not a good method, but it can work.
Thanks men!

yixuan
Shanghai
 
  


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
get rid of "printk: # messages suppressed" message android6011 Linux - General 4 10-04-2010 06:37 AM
printk(KERN_DEBUG ...) vs printk(...) Sergei Lavrov Linux - Kernel 2 03-25-2007 04:41 PM
linux kernel: printk: 39476 messages suppressed. seanfitz Mandriva 4 04-19-2005 04:36 PM
printk messages in Fedora 2 TracyHarmer Linux - Newbie 3 11-28-2004 04:42 PM
output of printk can NOT be found in /var/log/messages linshu Linux - Software 1 02-13-2004 09:06 AM


All times are GMT -5. The time now is 10:19 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration