Testing success of \write18

47 views
Skip to first unread message

Martin Scharrer

unread,
Mar 18, 2011, 3:54:35 PM3/18/11
to
(I was asking this already on TeX.SX (http://tex.stackexchange.com/
questions/13226/test-success-of-write18), but without a complete
answer and also like take advantage of the knowledge of the c.t.t.
readers.)

Is it possible to test the success of \write18, i.e. test if the shell
command has been executed by (La)TeX or disabled because of active
shell restrictions? I'm aware of the possibilities to test if the '-
shell-escape' option is enabled, disabled or set to the restricted
mode (\ifeof18, \pdfshellescape and the pdftexcmds package).
Things are easy when the shell escape option is enabled or disabled
completely.
However, in restricted mode I would like to know if the specific
command(s) I executed were permitted, i.e. have been added to the list
of trusted programs in `texmf.cnf` (for TeXLive).

The required information is already written into the log file:

runsystem(<command>)...disabled.
runsystem(<command>)...executed.
runsystem(<command>)...executed safely (allowed).
runsystem(<command>)...disabled (restricted).

Is there a way to test the success of \write18 calls in the code?
(Without hacks which parse the log file :-) )
I like to provide a user interface and report the success or failure
properly to the user.
Actually catching the return value of the \write18 call would be even
better!

Best Regards,
Martin Scharrer


Heiko Oberdiek

unread,
Mar 18, 2011, 4:08:40 PM3/18/11
to
Martin Scharrer <martin....@gmail.com> wrote:

> Is it possible to test the success of \write18, i.e. test if the shell
> command has been executed by (La)TeX or disabled because of active
> shell restrictions? I'm aware of the possibilities to test if the '-
> shell-escape' option is enabled, disabled or set to the restricted
> mode (\ifeof18, \pdfshellescape and the pdftexcmds package).
> Things are easy when the shell escape option is enabled or disabled
> completely.
> However, in restricted mode I would like to know if the specific
> command(s) I executed were permitted, i.e. have been added to the list
> of trusted programs in `texmf.cnf` (for TeXLive).

As you have aready said:
* \ifeof18 (disadvantage: you must know the feature exists, otherwise
TeX complains with an error).
* \pdfshellescape (pdfTeX) or \shellescape (XeTeX) with
values 0 (disabled), 1 (enabled), 2 (restricted)
(pdftexcmds: \pdf@shellescape)

AFAIK missing is:
* Restricted mode: Is a program is allowed without trying?
* Can the program be found?
* Return code of the program that is executed.
* Quoting specification for the command call.
* ...

> Actually catching the return value of the \write18 call would be even
> better!

Agreed.

* Make a feature request (pdfTeX, LuaTeX, XeTeX)
* Implement the feature request and provide patch files.
That raises the chances that the feature request is accepted
and actually added.

--
Heiko Oberdiek

Martin Scharrer

unread,
Mar 18, 2011, 4:44:36 PM3/18/11
to
On Mar 18, 8:08 pm, Heiko Oberdiek <heiko.oberd...@googlemail.com>
wrote:

Thanks Heiko,

thanks for listing the missing features. I was looking for them and
couldn't find anything, but you can never be sure if you not just
overlooked them.

I forgot to mention that I target pdf(La)TeX.
In LuaTeX it should be easily implementable using Lua code.
I have no idea about XeTeX.

I followed your advice and opened a feature request, at least for
pdfTeX (http://sarovar.org/tracker/index.php?
func=detail&aid=4333&group_id=106&atid=496).
I don't think I will find time to write a patch for it anytime soon.

Best Regards,
Martin Scharrer


GL

unread,
Mar 18, 2011, 6:32:13 PM3/18/11
to
Le 18/03/2011 21:44, Martin Scharrer a écrit :
> On Mar 18, 8:08 pm, Heiko Oberdiek<heiko.oberd...@googlemail.com>
>> * Make a feature request (pdfTeX, LuaTeX, XeTeX)
>> * Implement the feature request and provide patch files.
>> That raises the chances that the feature request is accepted
>> and actually added.
>
> Thanks Heiko,
>
> thanks for listing the missing features. I was looking for them and
> couldn't find anything, but you can never be sure if you not just
> overlooked them.
>
> I forgot to mention that I target pdf(La)TeX.
> In LuaTeX it should be easily implementable using Lua code.
> I have no idea about XeTeX.
>
> I followed your advice and opened a feature request, at least for
> pdfTeX (http://sarovar.org/tracker/index.php?
> func=detail&aid=4333&group_id=106&atid=496).
> I don't think I will find time to write a patch for it anytime soon.

I thought pdfTeX development was stopped, superseeded by LuaTeX which
provides all the primitives of pdfTeX...
Am i wrong ?

> Best Regards,
> Martin Scharrer
>

Regards.

Philipp Stephani

unread,
Mar 18, 2011, 10:29:52 PM3/18/11
to
GL <goua...@gmail.com> writes:

Yes. LuaTeX doesn't provide all of pdfTeX's primitives (otherwise the
pdftexcmds package would be unnecessary), and there are commits to
pdfTeX all the time (http://foundry.supelec.fr/gf/project/pdftex/). Of
course you could argue that now that LuaTeX is fairly stable and
omnipotent and can emulate every detail of pdfTeX and XeTeX, the latter
two could be regarded as effectevely superseded...

--
Change “LookInSig” to “tcalveu” to answer by mail.

GL

unread,
Mar 19, 2011, 7:12:19 AM3/19/11
to
Le 19/03/2011 03:29, Philipp Stephani a écrit :

> GL<goua...@gmail.com> writes:
>>> I don't think I will find time to write a patch for it anytime soon.
>>
>> I thought pdfTeX development was stopped, superseeded by LuaTeX which
>> provides all the primitives of pdfTeX...
>> Am i wrong ?
>
> Yes. LuaTeX doesn't provide all of pdfTeX's primitives (otherwise the
> pdftexcmds package would be unnecessary), and there are commits to
> pdfTeX all the time (http://foundry.supelec.fr/gf/project/pdftex/). Of
> course you could argue that now that LuaTeX is fairly stable and
> omnipotent and can emulate every detail of pdfTeX and XeTeX, the latter
> two could be regarded as effectevely superseded...
>

» Development of PDFTeX has (in essence) stopped: the brave new world
» is to be LuaTeX.

Source: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=whatpdftex

??

Philipp Stephani

unread,
Mar 19, 2011, 8:26:46 AM3/19/11
to
GL <goua...@gmail.com> writes:

Well, there *is* obviously at least some development (commits, bug
tracker items, Thanh responding on the mailing list...), but I don't
know whether that are only bug fixes. So the development has in essence
stopped in the sense "amount of LuaTeX development >> amount of pdfTeX
development," but not in the sense "the project has been completely
given up and nobody ever writes code for it."

Robin Fairbairns

unread,
Mar 19, 2011, 9:25:35 AM3/19/11
to
GL <goua...@gmail.com> writes:

:-( rewrite added to list, noting clarification in followup to yours:

+ status of pdftex project (aten't dead yet)
--
Robin Fairbairns, Cambridge
my address is @cl.cam.ac.uk, regardless of the header. sorry about that.

Reply all
Reply to author
Forward
0 new messages