LinuxQuestions.org
Visit Jeremy's Blog.
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 12-01-2010, 07:48 AM   #1
mwilner
LQ Newbie
 
Registered: Nov 2010
Posts: 8

Rep: Reputation: 0
Redirecting output from stderr


I have seen a post where someone was explaining the virtuality of stdout and stderr and that it can be redirected with e.g. 2>file.txt but this apparently is not working for me!
I have a CUPS filter with fprintf(stderr,...) statements but don't know how to make these visible to me.

Can someone help me get the idea?

Thank you,
\Manfred
 
Old 12-01-2010, 08:16 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,999

Rep: Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190
You may need to put a little more out there than a reference to something which may or may not be the problem.
Display the filter you are using and I am sure someone will have some advice
 
Old 12-01-2010, 10:33 AM   #3
emmalg
Member
 
Registered: Jun 2009
Location: Spain
Distribution: Various, Ubuntu, Fedora, Open Solaris, Solaris, RHEL, CentOS
Posts: 64

Rep: Reputation: 16
I agree, there isn't really enough information here to provide a detailed response, however to give an equally vague response which may or may not help, stdout is "1" and stderr is "2" (stdin is 0).

So if you want to redirect the output of a command to a file you may write:

Code:
command > outfile.txt
To redirect only the stderr to a file you write:

Code:
command 2> outerr.txt
to redirect your standard error to the same file as your standard output:

Code:
command > outfile_and_error.txt 2>&1
Be aware though, if you use the last method, particularly for debugging, that stdout and stderr aren't synchronised. Your error message may turn up several lines earlier than the stdout messages when you think the programme should have failed.

If you run a google search for stdout stderr you should be able to find more information quite easily.

Also make sure that the output isn't being redirected to /dev/null anywhere.

Emma
 
Old 12-01-2010, 11:59 AM   #4
mwilner
LQ Newbie
 
Registered: Nov 2010
Posts: 8

Original Poster
Rep: Reputation: 0
Ok, thanks for the advice about detail.
I am writing/debugging a CUPS filter that has fprintf(stderr...) statements to show at various states the values of variables.
When I am printing I expect these fprintf's to be hit and send the output to stderr.
While I am not sure where stderr has been redirected to /dev/null I am assuming it has since I don't see anything anywhere.
My question now is there a program or way to read these stderr outputs?

If I just redirect as described below inside a terminal it still doesn't catch the output from the CUPS filter while printing.
 
Old 12-01-2010, 12:30 PM   #5
emmalg
Member
 
Registered: Jun 2009
Location: Spain
Distribution: Various, Ubuntu, Fedora, Open Solaris, Solaris, RHEL, CentOS
Posts: 64

Rep: Reputation: 16
Ah ok. I'm beginning to see through the fog... :-)

Check the following link out which might give an indication as to why it isn't working and a possible solution:

http://lists.apple.com/archives/prin.../msg00004.html

A quick internet search using CUPS filter fprintf stderr gave a few results and a short glance through suggests that stderr from a filter will not be seen.

As I'm not sure what you're up to exactly I don't think I can offer any more help.

Cheers!
 
1 members found this post helpful.
Old 12-02-2010, 07:25 AM   #6
mwilner
LQ Newbie
 
Registered: Nov 2010
Posts: 8

Original Poster
Rep: Reputation: 0
Thank you emmalg this will guide me in my development.
\Manfred
 
  


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
redirecting stderr to file SPF Linux - Software 4 12-17-2007 06:56 AM
Redirecting STDERR iceman_san Linux - Newbie 13 08-10-2007 02:20 AM
redirecting stderr to a pipe dasy2k1 Linux - General 3 03-22-2007 11:28 AM
redirecting stdout and stderr to a file Avatar33 Programming 4 03-12-2005 07:55 AM
redirecting stderr nodger Programming 2 03-11-2004 10:58 AM

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

All times are GMT -5. The time now is 07:13 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
Open Source Consulting | Domain Registration