🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.os.linux.misc
7 messages
7 total messages Started by yuehong Sun, 17 Mar 1996 07:02
Help: how do you redirect compile error to a file
#37
Author: yuehong
Date: Sun, 17 Mar 1996 07:02
6 lines
533 bytes
I try to use the following command when I compile hello.cpp 
using gcc on linux:

g++ hello.cpp >bug

I thought error might be saved in bug. But, nothing there.
Re: Help: how do you redirect compile error to a file
#41
Author: Ravi K. Swamy
Date: Mon, 18 Mar 1996 05:37
14 lines
787 bytes
In article <4igdeo$8tf@news.jhu.edu>, yuehong <yuehong@psi.ece.jhu.edu> wrote:
>I try to use the following command when I compile hello.cpp 
>using gcc on linux:
>
>g++ hello.cpp >bug
>
>I thought error might be saved in bug. But, nothing there.

g++ hellp.cpp >& bug

Ravi
--
Ravi K. Swamy                http://www4.ncsu.edu/~rkswamy/www/
rkswamy@eos.ncsu.edu         root@genom.com
Re: Help: how do you redirect compile error to a file
#38
Author: frank.
Date: Mon, 18 Mar 1996 10:12
26 lines
1295 bytes
In article <4igdeo$8tf@news.jhu.edu>, yuehong@psi.ece.jhu.edu (yuehong) wrote:

> I try to use the following command when I compile hello.cpp 
> using gcc on linux:
> 
> g++ hello.cpp >bug
> 

Errors go to stderr, the '>' operator only redirects stdout. If you are
using sh/ksh/bash/... then you need 
   
   g++ hello.cpp >bug 2>&1

Basically, this tells the shell to redirect output to file descriptor 2
(stderr) to the same place that the output from file descriptor 1 (stdout)
is going to, which in this case is the file named "bug".

If you are using csh/tcsh/... then you need

   g++ hello.cpp >& bug

This tells the shell to redirect both stdout and stderr to the same file, "bug".

~Frank
 - Through the modem, past the router, over the firewall.. nothing but Net -
 -  PGP ID: 1C0F6685 | NCB#56 | Visit me --> http://www.tdx.org/~fcusack/  -
Re: Help: how do you redirect compile error to a file
#40
Author: Andreas Christoph
Date: Mon, 18 Mar 1996 12:40
21 lines
1059 bytes
In article <4igdeo$8tf@news.jhu.edu>,
	yuehong@psi.ece.jhu.edu (yuehong) writes:
>I try to use the following command when I compile hello.cpp 
>using gcc on linux:
>
>g++ hello.cpp >bug
>
>I thought error might be saved in bug. But, nothing there.

Errors are reported to standard error (descriptor 2), so make it
g++ hello.cpp 2>bug

Bye,
Andreas

-- 
--------------------------------------------------------------------
Andreas Christoph
Alexanderstr. 292
26127 Oldenburg
--------------------------------------------------------------------
Re: Help: how do you redirect compile error to a file
#39
Author: Floyd Davidson
Date: Mon, 18 Mar 1996 15:27
28 lines
1167 bytes
fcusack@tdx.org wrote:
>In article <4igdeo$8tf@news.jhu.edu>, yuehong@psi.ece.jhu.edu (yuehong) wrote:
>
>> I try to use the following command when I compile hello.cpp 
>> using gcc on linux:
>> 
>> g++ hello.cpp >bug
>> 
>
>Errors go to stderr, the '>' operator only redirects stdout. If you are
>using sh/ksh/bash/... then you need 
>   
>   g++ hello.cpp >bug 2>&1

And if you do this:

     g++ hello.cpp 2>&1 | tee bug

It will also display on the screen (as well as be sent to a file).
This works fine with make too:

     make 2>&1 | tee make.out

is the way I run make all the time.

  Floyd
-- 
Floyd L. Davidson          Salcha, Alaska         floyd@tanana.polarnet.com
Re: Help: how do you redirect compile error to a file
#42
Author: Daniel-Marian Baboiu
Date: Thu, 28 Mar 1996 23:07
24 lines
1339 bytes
yuehong wrote:
> 
> I try to use the following command when I compile hello.cpp
> using gcc on linux:
> 
> g++ hello.cpp >bug
> 
> I thought error might be saved in bug. But, nothing there.

'>' redirects the standard output; the compiler errors are on the
standard error; it happens that both are mapped to the screen. 

What you have to do is (if you are using bash as shell)
g++ hello.cpp >bug 2>&1


-------------------------------------------------
Daniel-Marian Baboiu
University of Central Florida / CREOL
4000 Central Florida Blvd
Orlando, FL 32816-2700
407-823-6919       Fax: 407-823-6955
e-mail: daniel@soliton.creol.ucf.edu
--------------------------------------------------
Re: Help: how do you redirect compile error to a file
#43
Author: Eddie Bush
Date: Sun, 31 Mar 1996 12:08
43 lines
1912 bytes
Daniel-Marian Baboiu wrote:
> 
> yuehong wrote:
> >
> > I try to use the following command when I compile hello.cpp
> > using gcc on linux:
> >
> > g++ hello.cpp >bug
> >
> > I thought error might be saved in bug. But, nothing there.
> 
> '>' redirects the standard output; the compiler errors are on the
> standard error; it happens that both are mapped to the screen.
> 
> What you have to do is (if you are using bash as shell)
> g++ hello.cpp >bug 2>&1
> 
> -------------------------------------------------
> Daniel-Marian Baboiu
> University of Central Florida / CREOL
> 4000 Central Florida Blvd
> Orlando, FL 32816-2700
> 407-823-6919       Fax: 407-823-6955
> e-mail: daniel@soliton.creol.ucf.edu
> --------------------------------------------------

another handy way to do this is to generate a script file using (what 
else) the script command.

This works like:

1) type script
2) gcc file.c
3) type exit

The default name for the script is typescript, but if you add a name 
parameter to script, you can change that (ie. "script errors" would 
generate a script named errors) if you like.  This is a handy method - at 
least it is to me.

This only works under Unix though - as far as I know.  Also - and someone 
(like you won't) PLEASE correct me if I am wrong - this should work on 
all UN*X machines.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads