<div>Thanks a lot for the sugestions!</div>
<div>I am going to try them...</div>
<div> </div>
<div>pedro<br><br> </div>
<div><span class="gmail_quote">On 4/5/06, <b class="gmail_sendername">Björn Bringert</b> <<a href="mailto:bringert@cs.chalmers.se">bringert@cs.chalmers.se</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Benjamin Franksen wrote:<br>> On Wednesday 05 April 2006 20:32, Pedro Miguel Duarte wrote:<br>><br>>>I am writing a Java program with a call to a Haskell module
M.hs,<br>>>in order to evaluate some expression expr.<br>>><br>>>A very simple idea, which I got somewhere in the net, is to create a<br>>>Process object p which executes a GHC command-line instruction:
<br>>><br>>>Process p = Runtime.getRuntime();<br>>>p.exec( " ghc M.hs -e \"expr\" " );<br>>><br>>><br>>>This would be very simple, if it worked...<br>>><br>>>
<br>>>My problem is that expressions i want to evaluate involve<br>>>strings, and GHC command-line 'ghc' misinterprets some special<br>>>symbols when it parses double quoted strings.<br>>><br>>>For instance,
<br>>> ghc -e " reverse \"2<3\" " gives an error!<br>><br>><br>> Hmm. On my Linux machine (running zsh):<br>><br>> ben@sarun: .../play/ghc-e > ghc -e " reverse \"2<3\" "
<br>> "3<2"<br>><br>> But now I see that you run 'p.exec' in Java which probably translates<br>> (more or less) to a 'exec' system call. 'exec' is not a shell, it<br>> cannot translate complex quotings and unquotings. I would try
<br>><br>> p.exec( "/bin/sh ghc M.hs -e \"expr\" " );<br>><br>> or something similar.<br><br>Another way could be to use one of the other exec() methods (which BTW<br>are available from the Runtime class, not the Process class). For
<br>example, using the "exec(String[] cmdarray)" version, you could write<br>something like (not tested):<br><br>Runtime r = Runtime.getRuntime();<br>Process p = r.exec(new String[]{"ghc", "-e", expr});
<br><br>/Björn<br></blockquote></div><br>