LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-16-2011, 11:14 AM   #1
thehadar
LQ Newbie
 
Registered: Aug 2011
Posts: 18

Rep: Reputation: Disabled
how can I redirect the messages sent from kernel to a user app's stdin?


Hi,

I have an application that prints to a log what it gets from its stdin. I would like this application to also print to log messages the kernel creates(I.e. the same messages displayed by dmesg app).
How can I do it?

In other words, can I redirect the kernel messages (I.e. sent using printk) to an application's stdin pipe?

Thanks!
Hadar
 
Old 08-18-2011, 12:49 AM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650
rsyslog supports "named pipes" and "shell execute" actions, may one of these would suit. See 'man rsyslog.conf'
 
Old 08-18-2011, 02:36 AM   #3
thehadar
LQ Newbie
 
Registered: Aug 2011
Posts: 18

Original Poster
Rep: Reputation: Disabled
Thanks. I already found a different solution. I sent /proc/kmsg and other applications' stdout to a fifo, and use this fifo as an input file to my application.

Something like this:

mkfifo /tmp/misfifo;
cat /proc/kmsg > /tmp/misfifo &
... # Send other appluications logs to myfifo. E.g. ./CoolApp > /tmp/misfifo &
./MyApp < /tmp/misfifo # Use misfifo as an input file to my application

It works.
Thanks again!
Hadar
 
Old 08-18-2011, 10:57 PM   #4
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650
Cool, but doing "cat /proc/kmsg > /tmp/misfifo" is a manual process as opposed to redirecting automatically via rsyslog

kernel -> rsyslog -> named pipe/fifo -> your app
 
  


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
how to redirect STDIN to hp-ux's passwd chickenjoy Other *NIX 3 04-24-2010 09:17 AM
redirect kernel messages to a telnet session? leniviy Linux - Kernel 3 01-14-2010 03:13 PM
stdin redirect billysdomain Linux - Newbie 5 12-17-2009 03:03 PM
bash stdin redirect Yustu Programming 3 03-13-2009 08:01 PM
how to redirect kernel messages to user files sharad durgawad Linux - Software 4 12-09-2005 08:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:58 PM.

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