calling a seperate program and supplying command line args.

Hal Daume III hdaume@ISI.EDU
Thu, 8 Aug 2002 15:25:33 -0700 (PDT)


You should probably use POpen (if you're reading from a pipe).  POpen is
available from:

  http://www.01.246.ne.jp/~juhp/haskell/popenhs/

here's a short program that uses it (it's pretty easy to figure out what's
going on, apologies for the lack of commenting):

wn = "/nfs/mendels1/wordnet1.6/bin/wn"
doSem hd = 
    do let word = hd
       (sem,_,_) <- popenEnvDir wn [word, "-hypen", "-hypev"] Nothing
                        (Just 
[("WNHOME","/nfs/mendels1/wordnet1.6"),("path","/nfs/mendels1/wordnet1.6/bin")]) Nothing
       return (findSem (readWordNet $ lines sem,word))
    where findSem (x,y) | '%' `elem` y  = PERCENT  
			| '$' `elem` y  = MONEY  

basically, use popenEnvDir, give it the executable, the arguments as a
list, something i don't remember, an environment (if you want) and then
it'll give you the output in the first of the triple.  see the docs for
what the rest does...

--
Hal Daume III

 "Computer science is no more about computers    | hdaume@isi.edu
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume

On Fri, 9 Aug 2002, Jason Smith wrote:

> How to basically?
> 
> I've not had much luck finding much in the way of doc's in ghc on how to do this?...basically I have a compiler in haskell and I want to call a parser which is written in Java.  The parser is a .NET binary, it spits out a text file containing the parse tree which I then suck up and do the usual compiler things with.  I need to supply the java parser command line args i.e the file to parse etc.. 
> 
> Thanks heaps
> Jason.
>