Edit: I have since upgraded to release 2.37 with the same result.

I'm running asymptote 2.15 on Windows 7. I'm trying to use the int system(string s) command for the first time to call a system command. The manual says...

If the setting safe is false, then the functions int system(string s) and int system(string[] s) can be used to call the arbitrary system command s.

I created a file sample.asy containing

int i = system("dir");

and call it with

asy runThermalModel.asy -nosafe

The resulting output at the command line is

Cannot execute dir

I get similar output for other DOS commands that I have tried. Can someone tell me how to properly use the system() function?

  • Under Linux it works. Path problem or some W7 permission ? Or launch command tool with full path.
    – O.G.
    May 10, 2016 at 20:06
  • Oddly enough, I get exactly the same error on my Mac when I try system("dir"). Have you tried using linux/unix commands (e.g., system("ls")) instead of DOS commands? May 11, 2016 at 4:24
  • @O.G.: I assume that the command should run in the same directory containing the asy file and I do have permissions there. I'm not sure what the last sentence means in the context of the system command. Thank you for letting me know that it works on Linux.
    – James
    May 11, 2016 at 11:26
  • @CharlesStaats: The ls command didn't work either (Cannot execute ls). I'm using the pre-compiled binary for windows. Do you think that perhaps there was a configuration flag disallowing system calls when the binary was created? I don't see anything in the manual about that being a possibility though.
    – James
    May 11, 2016 at 11:30
  • 1
    Hmm, works for me on Win 10 using the latest released version.
    – MindV0rtex
    May 11, 2016 at 20:46


You must log in to answer this question.

Browse other questions tagged .