tags:

views:

164

answers:

3

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

Something like an os.Exec.

+2  A: 

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

Dave McClelland
Works for me. Thanks.
Clark Gaebel
@Clark Great, glad I could be of assistance
Dave McClelland
+8  A: 

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.

Don Stewart
Note if you actually wish to copy a file you should use [copyfile](http://haskell.org/hoogle/?hoogle=%3A%3A+FilePath+-%3E+FilePath+-%3E+IO+%28%29).
TomMD
+1  A: 

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

Magnus