Say there's a C++ code that I've compiled into an executable using:
g++ test.cpp -o testcpp
I can run this using Terminal (I'm using OS X), and provide an input file for processing inside the C++ program, like:
./testcpp < input.txt
I was wondering if doing this is possible, from within Haskell. I have heard about the
readProcess function in
System.Process module. But that only allows for running system shell commands.
out <- readProcess "testcpp"  "test.in"
out <- readProcess "testcpp < test.in"  ""
out <- readProcess "./testcpp < test.in"  ""
throws out this error (or something very similar depending on which one of the above I use):
testcpp: readProcess: runInteractiveProcess: exec: does not exist (No such file or directory)
So my question is, whether doing this is possible from Haskell. If so, how and which modules/functions should I use? Thanks.
Ok, so as David suggested, I removed the input arguments and tried running it. Doing this worked:
out <- readProcess "./testcpp"  ""
But I'm still stuck with providing the input.