# Running external program from command line

This command works on Windows:

 ReadList["!" <> "echo hello", String]


Assuming the "!" suggests Windows command shell (verified as $SystemShell), However, I tried the above code in msys.bat which is a Unix-type shell on Windows, and it did not work. How can I do the above operation if it is not a Windows command shell? Do I need to replace "!" or change $SystemShell somewhere?

I have tried RunProcess (or ReadList) as:

 path = "C:\\MinGW\\msys\\1.0\\msys.bat";

RunProcess[path, "StandardOutput", "echo Hello world
exit
"]


This opens msys.bat in a new window, and Mathematica keeps running.

• Perhaps reference.wolfram.com/language/ref/RunProcess.html can be useful. – ilian May 14 '15 at 7:45
• @ilian I tried RunProcess[], did nt work, edited question. – kamuli May 14 '15 at 16:41
• I know that RunProcess only runs executables, not batch files (which must be interpreted by the windows shell). ReadList may have the same problem. – 2012rcampion May 14 '15 at 16:56
• Maybe the process executed could be cmd /c msys.bat or similar? – ilian May 14 '15 at 16:59
• I'm not very familiar with MinGW, the parent project of MSYS, but my understanding is that msys.bat is only a wrapper for starting a bash shell, but it's not a command interpreter itself, so you can't really pass it shell commands to it. – MarcoB May 14 '15 at 18:42

One approach could be to bypass msys.bat (which I think is primarily concerned with setting up the interactive console) and start the shell executable directly:
In[1]:= shell = "C:\\MinGW\\msys\\1.0\\bin\\bash.exe";