[Haskell-cafe] Execution of external command

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Thu Dec 13 08:51:20 EST 2007


On Thu, 2007-12-13 at 15:06 +0200, Yitzchak Gale wrote:
> Hi Bulat,
> 
> You wrote:
> > please help me with selection of proper function to use
> >
> > i need to run external command with parameter and get its stdout, smth
> > like this:
> >
> > output <- system "cmd param"
> >
> > the code should be compatible with unix and windows, and it should be
> > possible to execute scripts (so afaiu it should execute command via
> > cmd/sh). i use ghc 6.6.1 and it will be great if this function will
> > not require any non-bundled libs and be compatible with later ghc
> > versions
> 
> 
> OK, I'll bite. What's wrong with runInteractiveCommand?

It requires threads to use correctly and it is only available in GHC,
not in hugs, nhc98 etc.

It requires threads because you have to pull from both the stdout and
stderr to prevent blocking. You could do it with non-blocking reads but
not without busy-waiting.

Duncan



More information about the Haskell-Cafe mailing list