LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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 05-12-2009, 02:51 AM   #1
hawkgao
LQ Newbie
 
Registered: May 2009
Posts: 2

Rep: Reputation: 0
Question Cannot redirect all stdout and stderr into file


Hello, folks,
I have a little complex Makefile system. A parent Makefile call dozens of Makefiles in subdirctories. And the subdirctory Makefile calles shell script to do real building. I want to grab all output this Makefile system generate. So, i employ "make 2>&1 > make.log". but not all output messages are filed into make.log. The message generated by sub-makefile called shell script cannot be recorded into make.log. And another curiouse thing is, if i launch "make 2>&1 > make.log" in a perl script, all output do be sent into make.log.
Anybody can help me this? Thanks in advance!

Hawk

Last edited by hawkgao; 05-12-2009 at 02:55 AM.
 
Old 05-12-2009, 05:30 AM   #2
Robhogg
Member
 
Registered: Sep 2004
Location: Old York, North Yorks.
Distribution: Debian 7 (mainly)
Posts: 653

Rep: Reputation: 85
One of the quirks of redirection in the shell is, you have to redirect STDOUT first, then redirect STDERR into it:
Code:
make >make.log 2>&1
Can't really explain why it worked otherwise from Perl.
 
Old 05-12-2009, 09:14 AM   #3
hawkgao
LQ Newbie
 
Registered: May 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Thumbs up

Oh yes! I remember other guy writes this in perl is like "make >make.log 2>&1" as you do. I made mistake by using 2>&1 ahead >make.log. Thanks alot!!
Quote:
Originally Posted by Robhogg View Post
One of the quirks of redirection in the shell is, you have to redirect STDOUT first, then redirect STDERR into it:
Code:
make >make.log 2>&1
Can't really explain why it worked otherwise from Perl.
 
  


Reply

Tags
redirection


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
Perl stderr&stdout redirect question Fredde87 Programming 5 03-26-2009 04:43 AM
send stderr to a file and also to stdout pranavchoudhary Linux - Newbie 7 08-25-2008 01:57 AM
Shell script - stdout & stderr to terminal and file jantman Linux - Software 1 12-07-2006 04:34 PM
redirecting stdout and stderr to a file Avatar33 Programming 4 03-12-2005 07:55 AM
TCSH: redirect stdout and stderr seperately ugenn Linux - General 2 06-06-2002 12:07 PM


All times are GMT -5. The time now is 12:43 PM.

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