开发者

Executing a system command in Haskell

开发者 https://www.devze.com 2023-01-11 13:50 出处:网络
How could I execute a system command such as cp somefile somedestination in Haskell?开发者_JS百科

How could I execute a system command such as cp somefile somedestination in Haskell?

开发者_JS百科

Something like an os.Exec.


The Haskell 98 standard provides:

System.system :: String
              -> IO GHC.IO.Exception.ExitCode

which executes a command.

The new System.Process library is more useful though, allowing for portable input/output redirection and so forth.


import System.Process

main = callCommand "cp somefile somedestination"

just works, but you may prefer other functions from the System.Process module.


I'm not a haskell buff, but this may be what you're looking for


If you do this sort of thing a lot then it's worth having a look at http://hackage.haskell.org/package/HSH.

0

精彩评论

暂无评论...
验证码 换一张
取 消