# Tag Info

35

Note: If you're using this package, please let us know how! Understanding how people use it helps us improve it in the right areas. There is a new cross platform package for this, called MATLink. It allows calling MATLAB functions seamlessly, directly from Mathematica, as well as transferring data between the two systems. See below for a small ...

11

You can call an external (shell) command cmd without showing a command window by using the pipe syntax "!"<>cmd. This can be used in place of a filename with any Mathematica function that opens a file for reading. For example: Import["!dir", "Text"] Read["!dir"] (opens stream, must be closed) OpenRead["!dir"], followed by Read, ReadList etc to grab ...

10

You will find a complete, step by step description of how to write such a program here. Here's a small test program that adds 42 and 137, written by following the tutorial closely: /* mlcall.c */ #include <mathlink.h> #include <stdio.h> int main(int argc, char *argv[]) { MLENV env; MLINK link; int errno; int packet; env = ...

8

The number 2045 is suspicious. Add three to it to include stdin, stdout, and stderr, and you get 2048, which I suspect is total number of file descriptors available to you. I conclude your problem is caused by eating up all the available file descriptors. This is usually caused by doing too many file opens without doing any file closings to return some file ...

8

I would say JLink is one of the fastest ways to do this. Just use the Runtime to start a process executing your command and collect the exit code too: << JLink RunThroughWithExitCode[cmd_String] := JavaBlock[Module[{ireader, istream, runtime, process, reader}, LoadJavaClass["java.lang.Runtime"]; runtime = RuntimegetRuntime[]; process = ...

7

The problem has nothing to do with OpenWrite. You never Close the stream you open in your call to Read. Read, unlike ReadList, does not automatically close a stream (file, pipe, etc.) that's given as its first argument string. (That's because the purpose of Read is to be able to read from the same source in pieces, unlike ReadList which does it all at ...

7

I'll leave this up on GitHub, but I won't maintain the port. I recommend using MATLink instead. There's a package on the Wolfram Library Archive called mEngine that allows calling MATLAB from Mathematica. What it can do is: execute arbitrary MATLAB commands and retrieve their output as a string transfer array variables between Mathematica and MATLAB ...

6

Using a slightly modified version of vngx-jsch (source included), an open-source implementation of jsch, and JLink and a small but efficient Mathematica package this is now easily possible. All code can be browsed here, and most simply be installed by executing these lines: (tested on Windows and Linux, not on Mac). It should all work on Mathematica 7, 8 or ...

2

I solved the problem! The solution is quite simple. It is not allowed to distribute the definition of an indirect function to the sub-kernels. Thus, if we do not use ceteris paribus In[17]:= (* DistributeDefinitions[callVert] *) then setting the option DistributedContexts :> None by In[18]:= Map[SetOptions[#,DistributedContexts :> None]&, ...

1

As Anon pointed out, my problem was more of a poor knowledge of Unix rather than incomplete Mathematica chops, and a judicious use of pipes solves the issue. Thus, instead of exporting a string to a file and using that as an input, as I had, inputstring="sample input data"; Export["inputFile.txt",inputstring,"Text"] inputstream=OpenRead["! ...

Only top voted, non community-wiki answers of a minimum length are eligible