# Run external process with Run fails

When trying to execute an external process named sim.out with Run, Mathematica returns a number (e.g., 35584), but does not run the process. Although I specified the path of the process absolutely it does not work. However the process is executed correctly when I set the working directory to the notebook's directory.

This does not work:

path = FileNameJoin[{NotebookDirectory[], "sim.out"}];
Run[path]


This works as expected:

dir = SetDirectory[NotebookDirectory[]];
path = FileNameJoin[{NotebookDirectory[], "sim.out"}];
Run[path]


The 2nd example returns 0 and evaluates sim.out correctly.

Can anyone explain this behaviour to me?

• use SystemOpen for this looks more comfortable. – happy fish Jul 3 '16 at 15:22
• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – Michael E2 Jul 3 '16 at 16:17
• It would probably help to state your operating system – mikado Jul 3 '16 at 16:27
• Are you sure that the file you are trying to run exists? Are you sure that it is executable? Are you sure that it doesn't run? If yes, what evidence do you have? Maybe it runs but crashes immediately. Also, what is the precise number that Run returns? What is your operating system? – Szabolcs Jul 3 '16 at 17:21
• If the code was really 35602, that's 8b12 in hexadecimal. According to this it means termination with SIGQUIT and that the core was dumped (assuming you're on some sort of unix). I don't know what that means. – Szabolcs Jul 3 '16 at 17:40