On 11/1/21 3:10 PM, Taco Hoekwater via ntg-context wrote:
[...] Is there a way to wrap os.exec() in the sample so that it only runs if "dir" is available?
if os.which(‘dir’) then ... end
But note that os.which() may be unreliable in various cases (like it will fail for shell/command interpreter builtins, in cron jobs, in special scripted environments, and may incorrectly succeed for disabled/forbidden commands), as it just runs through the PATH environment variable to check for executable file existence. Many thanks for your reply, Taco.
This is exactly what I needed.
Often times, it is better to just try to run the command to see if that produces satisfactory results. It makes sense, but I cannot do that on foreign computers.
Many thanks for your help again, Pablo -- http://www.ousia.tk