MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Running programs from the command line in Mathematica


I've posted to this effect before, but normally you can capture the
output from terminal commands with ReadList or Import which provide
various possibilities for parsing it.  Try


Import["!dir", "Text"]         (on Windows)

ReadList["!dir", Record]      (on Windows)

Import["!ls", "Lines" ]       (on Unix-like)

ReadList["!ls", Record]       (on Unix-like)

The exclamation mark is essential to distinguish the command from a
file name.

John Jowett


On Jul 25, 12:21 pm, Steven Siew <stevensi... at gmail.com> wrote:
> It seems Run[] does not capture any output from the program run.
>
> <from the online manual>
>
> It is important to realize that Run never =93captures=94 any of the o=
utput
> from an external command. As a result, where this output goes is
> purely determined by your operating system. Similarly, Run does not
> supply input to external commands. This means that the commands can
> get input through any mechanism provided by your operating system.
> Sometimes external commands may be able to access the same input and
> output streams that are used by Mathematica itself. In some cases,
> this may be what you want. But particularly if you are using
> Mathematica with a front end, this can cause considerable trouble.



  • Prev by Date: Re: Cube root of -1 and 1
  • Next by Date: Re: ParametricPlot precision problem
  • Previous by thread: Re: Running programs from the command line in Mathematica
  • Next by thread: Sending Objects from Java - Mathematica