how to save the GHC errormessages in a file on Windows

When I try in Windows in cmd: ghc --make myprogram.hs > test.txt I only get the first lines in test.txt. The errormessages itself are on the screen, not in test.txt. In test.txt: Resolving dependencies... Configuring ftphs-1.0.7... Preprocessing library ftphs-1.0.7... Preprocessing executables for ftphs-1.0.7... Building ftphs-1.0.7... The errormessages: Could not find module 'Network.FTP.Client'.... and a lot more. How do I 'intercept' these messages? Kees

On Thursday 28 April 2011 14:31:29, Kees Bleijenberg wrote:
When I try in Windows in cmd: ghc --make myprogram.hs > test.txt I only get the first lines in test.txt. The errormessages itself are on the screen, not in test.txt.
In test.txt: Resolving dependencies... Configuring ftphs-1.0.7... Preprocessing library ftphs-1.0.7... Preprocessing executables for ftphs-1.0.7... Building ftphs-1.0.7...
The errormessages: Could not find module 'Network.FTP.Client'.... and a lot more.
How do I 'intercept' these messages?
The error messages are printed to stderr, while the others are printed to stdout. I'm not sure how it works on Windows, but on unix or linux, you'd redirect stderr with $ command 2> file.txt It's worth a try on Windows too, I think.
Kees

If you want all the output (stdout and stderr) to be redirected
together, doing "&>filename" redirects both stdout and stderr.
You can also redirect stderr to stdout by doing "2>&1" and then
redirecting the stdout to the file you need.
On Thu, Apr 28, 2011 at 10:04 AM, Daniel Fischer
On Thursday 28 April 2011 14:31:29, Kees Bleijenberg wrote:
When I try in Windows in cmd: ghc --make myprogram.hs > test.txt I only get the first lines in test.txt. The errormessages itself are on the screen, not in test.txt.
In test.txt: Resolving dependencies... Configuring ftphs-1.0.7... Preprocessing library ftphs-1.0.7... Preprocessing executables for ftphs-1.0.7... Building ftphs-1.0.7...
The errormessages: Could not find module 'Network.FTP.Client'.... and a lot more.
How do I 'intercept' these messages?
The error messages are printed to stderr, while the others are printed to stdout. I'm not sure how it works on Windows, but on unix or linux, you'd redirect stderr with
$ command 2> file.txt
It's worth a try on Windows too, I think.
Kees
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
-- Federico Mastellone Computer Science Engineer - ITBA ".. there are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." Tony Hoare, 1980 ACM Turing Award Lecture.

I believe those messages are written to stderr, not stdout. '>' redirects stdout, for stderr you need '2>'. HTH, Ozgur
participants (4)
-
Daniel Fischer
-
Federico Mastellone
-
Kees Bleijenberg
-
Ozgur Akgun