Peter Hall Peter Hall - 1 year ago 79
Bash Question

Is it possible to invoke bash or shell scripts from a haskell program?

I'm writing some shell scripts with haskell, which I'm running in gitbash, but there are a few other existing scripts I'd like to be able to use from those scripts.

For example, I'd like to run maven goals or do a git pull, but without having to integrate specifically with those tools.

Is there a way to do this?

Answer Source

You can use System.Process. For example, executing seq 1 10 shell command:

> import System.Process

> readProcess "seq" ["1", "10"] ""
it :: String

> readProcessWithExitCode  "seq" ["1", "10"] ""
it :: (GHC.IO.Exception.ExitCode, String, String)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download