Search code examples
rascal

Executing built-in commands


I would like to execute an external program from inside a Rascal program without creating a new process using createProcess() and killProcess(). Is this possible or have I missed something in the documentation?

Thanks.


Solution

  • It's a matter of calling the readEntireStream function:

    rascal>readEntireStream(createProcess("ls", ["-l","-a"]))
    str: "total 192drwxr-xr-x@ 5 jurgenv  admin    170 Mar 24 21:10 .drwxr-xr-x@ 5 jurgenv  admin    170 Mar  3 20:05 ..-rwxr-xr-x  1 jurgenv  admin  25160 Feb  4 18:43 eclipse-rw-r--r--@ 1 jurgenv  admin    637 Apr  3 13:58 eclipse.ini-rw-r--r--  1 jurgenv  admin  64679 Mar 24 21:10 hs_err_pid25121.log"