[Date Index]
[Thread Index]
[Author Index]
Re: RunThrough on Windows 2000
*To*: mathgroup at smc.vnet.net
*Subject*: [mg45354] Re: [mg45348] RunThrough on Windows 2000
*From*: Yasvir Tesiram <tesiramy at omrf.ouhsc.edu>
*Date*: Fri, 2 Jan 2004 04:23:43 -0500 (EST)
*References*: <200401011054.FAA17821@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
Hi,
Some notes, in my experiments with Run and RunThrough.
1. Use a text based Mathematica session and not a Notbook interface.
If you use a Notebook interface, then you have to write the output of any
shell command into a file that can be intepreted by Mathematica to give
you a Notebook.
2. If you use a Notebook interface, Run and RunThrough, will only give you
the status codes of the external command on completion of the external
command, with the exception of the cat command as below. Thus usually 0
means success and everything else is unsucessful. Some examples are given
below.
> In[60]:=
> RunThrough ["cat", 123]
> Out[60]=
> 123
>
> after a brief flash of the Mathematica-launched DOS box.
>
> If I embellish this example a bit, I get ...
>
> In[61]:=
> RunThrough ["cat", 123+456]
> Out[61]=
> 579
>
This is because 123+456 is a Mathematica expression and is equal to 579.
> These are not the results I expected, as when this 1991 "cat" is typed
> directly into the MKS DOS box I get ...
>
> C:\MKS> cat 123
> cat: 123: no such file or directory
This happens because you don't have a file called 123 on your system.
> C:\MKS> cat 123+456
> cat: 123+456: no such file or directory
Again, no file called 123+456.
>
> I'm baffled. Does this make sense to anyone?
==>Some examples follow.
Note, I have used a text based Mathematica session for the following
examples. If you use a Notebook interface you will get the status codes of
the command upon completeion.
In[13]:= expr1=123;
In[14]:= RunThrough["cat",expr1]
Out[14]= 123
In[16]:= RunThrough["cat",123+456]
Out[16]= 579
Here are some ways to suppress the evaluation.
In[17]:= RunThrough["cat","123+456"]
Out[17]= 123+456
In[18]:= RunThrough["cat",Hold[123+456]]
Out[18]= Hold[123 + 456]
In[19]:= RunThrough["cat",Hold[FullForm[123+456]]]
Out[19]= Hold[Plus[123, 456]]
The second argument to RunThrough is taken to be a Mathematica expression.
Now lets say you want read in the contents of a file or the output of some
external command into Mathematica. To read in you can use Get (<<). To
write out you can use Put (>>).
In[20]:= Table[i,{i,1,1000,1}] >> "/Users/yasvirat/tmpints"
In[21]:= Run["cat","tmpints"]
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, <snip>, 998, 999, 1000}
Out[21]= 0
If we say
In[22]:= RunThrough["cat","tmpints"]
the output is simply the expression you put in.
Out[22]= tmpints
Likewise for
In[23]:= RunThrough["cat",tmpints]
Out[23]= tmpints
To force RunThrough to do what Run does, you can make a Mathematica
expression like;
In[26]:= expr2="Run[\"cat\", \"/Users/yasvirat/tmpints\"]"
Out[26]= Run["cat", "/Users/yasvirat/tmpints"]
In[27]:= RunThrough["cat",ToExpression[expr2]]
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, <snip>, 998, 999, 1000}
Out[27]= 0
I don't expect this behaviour to be any different for a Windows 2000, just
the syntax of how you express filenames etc.
Cheers
Yas
Prev by Date:
**Re: How to copy pattern from one expression to another?**
Next by Date:
**Re: Mathematica + NETLink + CodeDom- Example 2**
Previous by thread:
**RunThrough on Windows 2000**
Next by thread:
**Re: RunThrough on Windows 2000**
| |