I have ghc 6.12.3 and Ubuntu 11.04 installed on my laptop.
I would like to have a function that accepts some shell commands and executes them as superuser (e.g. sudo update-manager, sudo iwlist ....) in Haskell. I know that the System.Process module has some functions, such as createProcess, runInteractiveCommand. But there is for one raw command or one shell command, and not for compound commnads, such as "sudo update-manager". All my experiments on these functions to execute "sudo ..." have failed. The terminal that I used to run my haskell function did not respond.
I also looked at the HSH package. But it seems to me that the functions exported there are also not suitable for sudo commands.
I assume that it takes two processes to execute commands like "sudo update-manager". One for sudo and one for update-manager. Therefore, I need to call the "createProcess" functions twice and somehow bind them so that the second process for "update-manager" gets the superuser privilege from the first process for "sudo".
Thanks in advance for your help!
shell haskell sudo
chenxicali
source share