MathGroup Archive 2000

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

Search the Archive

Re: shell commands in notebooks

  • To: mathgroup at
  • Subject: [mg22186] Re: shell commands in notebooks
  • From: "P.J. Hinton" <paulh at>
  • Date: Thu, 17 Feb 2000 01:24:21 -0500 (EST)
  • Organization: "Wolfram Research, Inc."
  • References: <88dnnt$>
  • Sender: owner-wri-mathgroup at

On 16 Feb 2000, Wolfgang Schadow wrote:

> How can I execute shell commands from within a notebook? The book says
> !date
> or 
> Run["date"]
> This works fine in a terminal session, but not in a notebook. It seems
> that the commands are executed but the output is going somewhere else.
> To see this try
> Run["date > foo"]
> !!foo
> So what's happening with the output? (Mathematica 4.0 under Linux)

Neither the front end nor the kernel captures output (stdout or stderr)
from executables invoked by the kernel.  As a result the output is not
seen.  This is noted in _The Mathematica Book_ (Fourth Edition).  You can
retrieve this section of the documentation through the Help Browser by
executing the following command:

    {"2.11.12", "2.14"}

You can capture the output with a funciton like this.

RunCapture[cmd_String, arg__:""] := 
    {outfil = Close[OpenTemporary[]], result, stmp}, 
    Run[cmd, arg, ">", outfil];
    stmp = OpenRead[outfil];
    result = Read[outfil, Record, RecordSeparators -> {}];

P.J. Hinton
Mathematica Programming Group           paulh at
Wolfram Research, Inc.
Disclaimer: Opinions expressed herein are those of the author alone.

  • Prev by Date: Re: How to force saving in .m format?
  • Next by Date: Re: LogLogPlot trouble
  • Previous by thread: shell commands in notebooks
  • Next by thread: Re: shell commands in notebooks