1
$\begingroup$

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?

$\endgroup$
  • $\begingroup$ use SystemOpen for this looks more comfortable. $\endgroup$ – happy fish Jul 3 '16 at 15:22
  • $\begingroup$ 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! $\endgroup$ – Michael E2 Jul 3 '16 at 16:17
  • 1
    $\begingroup$ It would probably help to state your operating system $\endgroup$ – mikado Jul 3 '16 at 16:27
  • $\begingroup$ 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? $\endgroup$ – Szabolcs Jul 3 '16 at 17:21
  • 1
    $\begingroup$ 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. $\endgroup$ – Szabolcs Jul 3 '16 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.