Tag Info

Hot answers tagged

20

Get all the files here: http://JeremyThompson.net/Rocks/Mathematica/MmaWord.zip .Net Mathematica Word Library You will need to use a Microsoft library to open word documents. In a language such as .Net it is very easy; just open Visual Studio, reference the Microsoft.Office.Interop.Word .Net DLL (for Words) and the C:\Program Files\Open XML ...


8

Under most operating systems you can use the 2>&1 handle redirection operator(1),(2): Import["!foo 2>&1", "Text"] "'foo' is not recognized as an internal or external command, operable program or batch file."


7

The problem is that the stdin stream for each process is being left open and needs to be closed. To demonstrate the issue, we create a single process: $process = StartProcess[$SystemShell]; WriteLine[$process, "echo example line"]; KillProcess[$process]; The call to WriteLine implicitly creates a stream object. Even though the process has been killed, ...


7

There are many ways to do this on a Mac. For example to open Safari: << "!open -a Safari" To open Safari to a particular file or page: << "!open -a Safari http://mathematica.stackexchange.com/questions/69247/how-to-close-external-app-from-mathematica" Now to close Safari: << "!osascript -e 'tell application \"Safari\" to quit'"


6

On Windows this works: Run["taskkill /im chrome.exe /f"] Run["taskkill /im WolframPlayerPro.exe /f"]


6

For those who will encounter the same problem as mine (and OP's), I added this answer. Mathematica now(since 10.0.0) has a new built-in function called RunProcess which does exactly what OP asked (including the standard error).


5

We had a bug like this on v. 10: it specifically stopped running new processes after you created 100 of them. This was fixed in version 10.0.1. I recommend testing it there, as version 10.0.1 has a number of improvements with respect to StartProcess. I can't test your example in MacOS right now, so please let me know if this isn't working on v. 10.0.1. ...


5

You can ask MMA to run the traditional ps,grep,kill,killall "unix" shell commands (using for example the RunProcess and Runcommands). The following is more a "Unix" post than a Mathematica one, but ... : For Unix, OS X sytems To "check if some application is opened" :ps and grep For example to see if the Chrome browser is running : myExternalCommand = ...


3

I actually found 3 ways to execute your command with RunProcess (on Unix like systems) : Let's write your command as a string : mycommand = "mdfind -onlyin /some/folder my_string"; but it could be any other command like : mycommand = "ls -la"; Then these 3 inputs are equivalent : RunProcess[StringSplit@mycommand] RunProcess[{$SystemShell, "-c", ...


3

Update -- finally got version 10 StartProcess version: the fortran: program ptest real*8 x do while(.true.) read(*,*)x write(*,*)x**2*cos(x)+1.d0 enddo end this is a simple endless loop, reading from stdin and writing to stdout. now in mathemaitca: pr = StartProcess["ptest"]; f[x_?NumericQ] := (Write[pr, FortranForm[x]]; ...


1

To call an external command with input parameters like *argv[] in C (I don't know how is it called in Fortran) you can use this Mathematica routine: RunProcess[{$SystemShell, "-c", ExecutableFileName <> " " <> arg1 <> " " <> arg2 <> " " <> arg3}, "StandardOutput"] This will also give back output as a result of the ...



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