Difference among various logging methods
E-Neutrino
e-neutrino at web.de
Tue Jul 22 23:13:29 UTC 2014
Am 22.07.14 22:37, schrieb Sabniveesu Shashank:
> [Avoiding application specific details for brevity; Please ask if needed]
>
> Hi!
>
> I could log data from an NS3 script into terminal. To save it, I did
>
> ./waf --run=first|tee first.txt (I see output on terminal; just an
> empty file is created)
>
> ./waf --run=first > first.txt (I see output on terminal; just an
> empty file is created)
>
> ./waf --run=first >& first.txt (saved 327 MB)
>
> I found the last one in a blog. I don't understand why it alone is working.
>
> Can someone respond?
I don't know waf, but it looks like it outputs to stderr instead of
stdout. So the correct method would be
./waf --run=first 2> first.txt
or (if you want to use tee)
./waf --run=first 2>&1 | tee first.txt
the second form captures both stderr and stdout in first.txt
An alternative way (without parallel terminal output) would be
./waf --run=first > first.txt 2>&1
note the order of redirections: first you connect "first.txt" to the
stdout channel, then you connect the stdout channel into the stderr
channel. The other order would not work.
Hope this helps
Neutrino
--
Computers help us to solve problems we don't have without computers.
More information about the ubuntu-users
mailing list