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?
Shell scripting is scripting in any shell, whereas Bash scripting is scripting specifically for Bash. sh is a shell command-line interpreter of Unix/Unix-like operating systems. sh provides some built-in commands. bash is a superset of sh.
In computer programming, a script is defined as a sequence of instructions that is executed by another program. A shell is a command-line interpreter of Linux which provides an interface between the user and the kernel system and executes a sequence of instructions called commands.
You can use System.Process
. For example, executing seq 1 10
shell command:
> import System.Process > readProcess "seq" ["1", "10"] "" "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" it :: String > readProcessWithExitCode "seq" ["1", "10"] "" (ExitSuccess,"1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n","") it :: (GHC.IO.Exception.ExitCode, String, String)
Yes, it is possible. You can use process
package, which exports many useful functions. Simplest one is System.Cmd.system
, which can run some application in shell, yielding exit code.
More advanced features are provided too in the System.Process
module. With this module you can run process and communicate with it in many ways (input piping, exit codes, waiting for process to stop, modify its environment etc).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With