On 11/1/2021 2:26 PM, Pablo Rodriguez via ntg-context wrote:
Dear list,

is there a way if a program is installed on the computer using Lua.

I have the following sample:

   \starttext
   \startluacode
   filename = tex.jobname .. ".pdf"
   os.exec("dir " .. filename)
   \stopluacode
   \stoptext

Is there a way to wrap os.exec() in the sample so that it only runs if
"dir" is available?

I know that os.name would be an option here, but not in my real world
document.

\starttext
  \startluacode
    if lfs.isfile(tex.jobname .. ".pdf") then
        context("YES")
    end
    if lfs.isfile(file.addsuffix(environment.outputfilename,"pdf")) then
        context("YES")
    end
    if #dir.glob(file.addsuffix(environment.outputfilename,"pdf")) > 0 then
        context("YES")
    end
  \stopluacode
\stoptext

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to