redirecting stdin/stdout
Jonas Svensson
d99josve@dtek.chalmers.se
Tue, 20 Aug 2002 20:45:20 +0200
--y0ulUmNC+osPPQO6
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Tue, Aug 20, 2002 at 04:57:21AM -0700, Hal Daume III ->
> I would like to be able to semi-permanently redirect stdout
> particularly. That is, say something like:
>=20
> main =3D do
> h <- openFile "myoutput" WriteMode
> setStdOut h
> ..crux of the program..
> hClose h
>=20
> where any call which uses stdout either explicitly or implicitly (through
> putStr and the like) is redirecto to h.
>=20
> I didn't see anything of this sort in either the std libs IO or in the
> GHC.IO/IOBase modules...would such a thingbe possible?
If you are using UNIX the dupTo (in C dup2) function in the Posix
module might do the trick.
/jonas
--=20
%http://www.dtek.chalmers.se/~d99josve/ - d99josve@dtek.chalmers.se
%GPG:http://www.dtek.chalmers.se/~d99josve/pubkey.asc
--y0ulUmNC+osPPQO6
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.1 (SunOS)
Comment: For info see http://www.gnupg.org
iEYEARECAAYFAj1ijj4ACgkQR2UjjE3BMyo8lQCghs37kSTe80hJ/3f8dZlzLg83
FSUAn2wTU5WdNQ0YgyK+ZHPEZ1afm5AS
=Ld+K
-----END PGP SIGNATURE-----
--y0ulUmNC+osPPQO6--