module Graphics.Gnuplot.Execute where
import Graphics.Gnuplot.Private.OS (gnuplotName, )
import qualified System.IO as IO
import System.IO.Temp (withSystemTempFile, )
import System.Exit (ExitCode, )
import System.Process (readProcessWithExitCode, )
tmpScript :: FilePath
tmpScript = "curve.gp"
simple ::
[String]
-> [String]
-> IO ExitCode
simple program options =
withSystemTempFile tmpScript $ \path handle -> do
IO.hPutStr handle (unlines program)
IO.hClose handle
(exitCode, _out, _err) <-
readProcessWithExitCode gnuplotName (options ++ [path]) []
return exitCode