mathics / Mathics

This repository is for archival. Please see https://github.com/Mathics3/mathics-core
https://mathics.org
Other
2.08k stars 205 forks source link

Run command not supported #175

Open sn6uv opened 10 years ago

sn6uv commented 10 years ago

The ability to launch external commands, would be a nice addition

For example:

In[1]:= !python -c "print(1+1)"
2

This requires implementing the Run command [1] and adding some a special input rule to the frontend.

[1] http://reference.wolfram.com/mathematica/ref/Run.html

mrshu commented 10 years ago

@sn6uv This looks very interesting.

Do you think I could handle this?

sn6uv commented 10 years ago

@mrshu, yes I think so.

I'm not completely sure what will be required to get this working cross-platform, but if you use the subprocess module it should be okay.

As always, let me know if you need help.

mrshu commented 10 years ago

Thanks!

A few unsorted notes

sn6uv commented 10 years ago
In[1]:= Run["pwd"]
/home/angus

Out[1]= 0

In[2]:= Run["du", "-sh"]    (* Cancelled because it takes to long *)
^C
Out[2]= 2

In[3]:= Run["cat", "myexample.py"]
#!/usr/bin/python2
print 1 + 1

Out[3]= 0

In[4]:= Run["python2", "myexample.py"]
2

Out[4]= 0

In[5]:= Run["ipython2"]   (* Launches an interactive program *)
Python 2.7.5 (default, Sep  6 2013, 09:55:21) 
Type "copyright", "credits" or "license" for more information.

IPython 1.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: 1+4
Out[1]: 5

In [2]: print("abc")
abc

In [3]: 
Do you really want to exit ([y]/n)? 

Out[5]= 0
rocky commented 3 years ago

This is implemented in mathicsscript since 1.1.2. See https://github.com/Mathics3/mathicsscript/releases/tag/1.1.2

TiagoCavalcante commented 2 years ago

@rocky @mmatera already implemented in Mathics CLI too.