4

I need to run an external program to process some files. I have added the location of the program to my .bash_profile (I use a mac) and I have verified that executing the program in Terminal works.

However, whenever I execute Run["program"] Mathematica returns 32512. I suppose this is some error code but I can't find what it means.

Whatever idea you have will help me.

amrods
  • 637
  • 3
  • 13

1 Answers1

4

Your problem is likely to be that the program you are trying to run is not on the path that Mathematica is using. To see this you can use:

file = CreateTemporary[];
Run[StringJoin["echo $PATH >", file]];
FilePrint[file]

I get the following

/usr/local/Wolfram/Mathematica/11.0/Executables:/usr/local/Wolfram/Mathematica/11.0/SystemFiles/Graphics/Binaries/Linux-x86-64:/usr/local/Wolfram/Mathematica/11.0/Executables:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/bin/X11
mikado
  • 16,741
  • 2
  • 20
  • 54
  • right, I get only /usr/bin:/bin:/usr/sbin:/sbin, even when I edit my .bash_profile to add the path of the program I want to run... – amrods Aug 28 '16 at 19:48
  • 1
    Can you specify the full path to the program in the call e.g. Run["/path/to/program"]? Or use Run["bash -c Program"]? – mikado Aug 28 '16 at 20:09
  • Run with the full path works. What does bash -c program do? – amrods Aug 28 '16 at 20:30
  • 1
    It uses bash to run the program. If you have set up the path correctly for bash, it should then be able to launch the program. – mikado Aug 28 '16 at 20:32