The command Run
will do exactly that. For example, try
Run["touch ~/Desktop/blankfile"]
If you want to read the results back in, there are a few options, and the choice between them depends on exactly what you want to do.
The RunThrough
command lets you read the output of a command-line back as a Mathematica expression. For example, try
RunThrough["bc", 123 + 456]
579
The OpenRead
command can also run external comands, and returns the output as an InputStream
object. This can then be accessed using ReadList
and related commands, and allows for some fancier manipulations. For a basic example, try
ReadList[OpenRead["!echo hi"]]
Note, in particular, the use of an exclamation mark at the beginning of the OpenRead
argument. In general OpenRead["!command"]
is equivalent to typing command
into a terminal.
I should also mention that for many of the applications you might want to call - including C, C++, Java, .NET, and MATLAB - there are dedicated interfaces which are overwhelmingly likely to be more useful than a direct call on the terminal. Some of these can be accessed on the Calling External Programs guide; to communicate with MATLAB you should use MATLink.
Edit: it seems Mathematica v10 has expanded capabilities for starting, controlling, and talking to external processes. For more information, see Direct Control of External Processes in the documentation.