[Haskell-cafe] catch the stdout when execute a shell cmd

2007-01-23 Thread Forest Liu

I use system in System.Cmd to execute a shell cmd, then how can I
catch its stdout?

--
  Sincerely,
Forest Liu(刘云�S)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] catch the stdout when execute a shell cmd

2007-01-23 Thread Donald Bruce Stewart
oxware:
 I use system in System.Cmd to execute a shell cmd, then how can I
 catch its stdout?

Use System.Process,
http://haskell.org/ghc/docs/latest/html/libraries/base/System-Process.html

And example, call the 'date' program:

  (inh,outh,errh,pid) - runInteractiveProcess date [+%d:%m:%y] Nothing 
  Nothing
  hClose inh
  hGetContents outh
 24:01:07\n

Regards,
  Don

There's some wrappers to this floating around too, which should get into
base soon enough.. E.g. http://www.cse.unsw.edu.au/~dons/code/newpopen/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe