Tag Info

11

(Reposting my comment as an answer) The reason this is happening is that the Mathematica launcher script sets LD_LIBRARY_PATH so that libraries included in the layout will be found and used, and that setting is inherited by any external process started from the kernel. But, sometimes it may happen that the external executable is linked against a conflicting ...

7

I think this is an OS X issue. Note that if you launch Mathematica from a terminal, you will get the value of Environment["PATH"] which you expected. For GUI applications that are started through Finder/LaunchServices, the environment (and $PATH in particular) is different and determined by the OS (this is a related recent question that had to do with ... 7 On Windows this works: Run["taskkill /im chrome.exe /f"] Run["taskkill /im WolframPlayerPro.exe /f"] 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 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 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 = ... 4 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]]; ... 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", ...

2

It is certainly an OS X issue. Assuming the default shell is configured, when Terminal starts up it runs the script file ~/.bash_profile, which usually modifies the PATH environment variable. You can do the same thing in Mathematica with SetEnvironment["PATH" -> Import["!source ~/.bash_profile; echo $PATH", "Text"]] After which Environment["PATH"] ... 2 Let's override the Run so it stops acting up. Needs["NETLink"]; InstallNET[]; Unprotect[Run]; Run[x___] := Module[{t, p}, LoadNETType["System.IO.Directory"]; DirectorySetCurrentDirectory[Directory[]]; t = NETNew["System.Diagnostics.Process"]; t@StartInfo@FileName = "C:\\Windows\\System32\\cmd.exe"; t@StartInfo@Arguments = "/c " <> ... 2 Pretty easy just try the below code Run["racket -t foo.rkt -l racket -e '(hello ....)'"] I don't have mathematica on this system to check it for you right now though. the trick is to run racket through kernel try this code and let us know what happened it may need bit of tweaking. remember if you can't capture the output you have to send it to a file and ... 1 Run["start notepad C:\\Users\\Dimitris\\Desktop\\C32EXE\\composites.dat"]; Finish editing. Then: Run["C:\\Users\\Dimitris\\Desktop\\C32EXE\\composites.exe"]; 1 The following seems to work on Win7 for opening explorer.exe in a specified directory using a command line parameter: Module[{cmd = "C:\\Windows\\explorer.exe /e, \"" <>$UserAddOnsDirectory <>"\""}, Print@cmd; Run[cmd]] Also, Rui Liu (Wolfram Technical Support) provides this detailed answer regarding the vagaries of the Run command for ...

1

It may be possible - as noted by @MarcoB its quite a convoluted way of doing things. I would just download R and RStudio and work from there. However if you are set on using IBrokers via the R api via RLink try this (disclaimer it crashed for me on 10.1) : Needs["RLink`"]; InstallR[]; REvaluate["install.packages(\"IBrokers\")"]; ...

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