[Haskell] system command
Duncan Coutts
duncan.coutts at worc.ox.ac.uk
Tue Jul 4 05:37:01 EDT 2006
On Tue, 2006-07-04 at 11:22 +0200, J. E. Palomar wrote:
> Hi,
>
> I am newbie in Haskell programing and need to launch
> a shell command through a Haskell code.
> In other programing languages like C or Java I know how
> carry out this task; for instance the code
>
> system("ls -l ")
>
> in C or
>
> exec("ls -l")
>
> in Java work fine and lists the working directory.
> I know that in interactive mode the Haskell command
> :! ls -l
> is similar, but ¿It is possible something like in Haskell
> non-interactive mode?
The function you're looking for is called 'system' and is in the System
module.
System.system :: String -> IO ExitCode
it does just the same as the C and Java versions.
BTW, one way you could have found this out is to search using hoogle:
http://haskell.org/hoogle/
searching for 'system' gives the one we want as part of the search
results
http://haskell.org/hoogle/?q=system
and links to the detailed documentation:
http://haskell.org/ghc/docs/latest/html/libraries/base/System-Cmd.html#v
%3Asystem
Duncan
More information about the Haskell
mailing list