
Hello I try to execute a command using system. my code is like this system (unwords ["python", p]) where p :: FilePath p = "/my super/script.py" has you can see this path contain a space. When I try to run it I get an error python: can't open file '/my': So the system command is wrong. I understand that I need to escape the space in the command, like this p = "/my\ super/script.py" now is there a function in haskell for this. a sort of sanitizer for FilePath when used by system. Thanks Frederic

On 2017-01-26 10:50, PICCA Frederic-Emmanuel wrote:
Hello
I try to execute a command using system.
my code is like this
system (unwords ["python", p])
An easier way to execute programs is to use the functions defined in System.Process, e.g.: import System.Process main :: IO () main = callProcess "/usr/bin/python" ["/my super/script.py"] Note that 'callProcess' takes a list of strings, each element being one argument. The elements may contain spaces. -- Frerich Raabe - raabe@froglogic.com www.froglogic.com - Multi-Platform GUI Testing

thanks but I do not have a recent enough ghc in order to use this method (debian jessie) maybe I can use proc in order to prepare my command line ?

You can use the rawSystem function on older versions of the process package. On Thu, Jan 26, 2017 at 12:19 PM, PICCA Frederic-Emmanuel < frederic-emmanuel.picca@synchrotron-soleil.fr> wrote:
thanks but I do not have a recent enough ghc in order to use this method (debian jessie)
maybe I can use proc in order to prepare my command line ? _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
participants (3)
-
Frerich Raabe
-
Michael Snoyman
-
PICCA Frederic-Emmanuel