f



Running programs from the command line in Mathematica

Hello,

Basically, I would like to run the following command from Mathematica:

idl /users/burkart/idlpro/autoexportdata.bat

If I type this command into a terminal (I'm running Mac OSX Leopard), it works perfectly well. However, if I try the same thing using Mathematica's Run[] command, it does not execute and I get the following result:

In[9]:= Run["idl /users/burkart/idlpro/autoexportdata.bat"]

Out[9]= 32512

The error code Run[] produces is the same every time and I don't know what it means (might be OS-specific). The command, when executed from the terminal, is designed to self-quit after finishing. Is there some way to do what I'm trying to do?

Thanks in advance,
Josh Burkart

0
jburkart (3)
7/23/2008 10:20:11 AM
comp.soft-sys.math.mathematica 28821 articles. 0 followers. Follow

3 Replies
947 Views

Similar Articles

[PageSpeed] 42

Josh,

  If you do not mind me asking. What is idl?

  Also, can you try this:

Run["/usr/bin/date"]

Run["idl","/users/burkart/idlpro/autoexportdata.bat"]

Run["/some/path/idl","/users/burkart/idlpro/autoexportdata.bat"]


  Thank you

Steven Siew

On Jul 23, 8:20 pm, Josh Burkart <jburk...@ucdavis.edu> wrote:
> Hello,
>
> Basically, I would like to run the following command from Mathematica:
>
> idl /users/burkart/idlpro/autoexportdata.bat
>
> If I type this command into a terminal (I'm running Mac OSX Leopard), it =
works perfectly well. However, if I try the same thing using Mathematica's =
Run[] command, it does not execute and I get the following result:
>
> In[9]:= Run["idl /users/burkart/idlpro/autoexportdata.bat"]
>
> Out[9]= 32512
>
> The error code Run[] produces is the same every time and I don't know wha=
t it means (might be OS-specific). The command, when executed from the term=
inal, is designed to self-quit after finishing. Is there some way to do wha=
t I'm trying to do?
>
> Thanks in advance,
> Josh Burkart


0
7/25/2008 10:21:26 AM
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 output
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.

0
7/25/2008 10:21:37 AM
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...@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.


0
7/28/2008 11:54:56 AM
Reply: