Is it possible to run a shell script AND pass it arguments from Mathematica? I have searched thoroughly and been unable to find a way to do this.

I want to avoid having to write a .wls for this particular instance, although I am beginning to fear I may have to.

  • 3
    $\begingroup$ How about Run and RunProcess? $\endgroup$
    – C. E.
    Commented Jul 12, 2019 at 21:36
  • 1
    $\begingroup$ Also StartProcess is nice if you need to dynamically interact with it. $\endgroup$
    – b3m2a1
    Commented Jul 13, 2019 at 2:33

1 Answer 1


You can experiment with this code:

RunProcess[{"C:/Windows/System32/cmd.exe", "/C", "cd"}, "StandardOutput"] // FullForm
RunProcess[{"script.bat", "arg1", "arg2"}, "StandardOutput"] // FullForm

under Windows, or with UNIX use:

RunProcess[{"/bin/sh", "-c", "pwd"}, "StandardOutput"] // FullForm
RunProcess[{"/bin/sh", "-c", "script.sh arg1 arg2", "StandardOutput"] // FullForm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.