[tex-k] exit code and --interaction

Joachim Schrod jschrod at acm.org
Fri Oct 31 09:41:48 CET 2008


> I realise I forgot to mention the important point: I observe the strange
> behaviour only with newlines in the echoed string.
> I originally noticed it in a Perl script, doing something like :
> $source = <<EOF;
> \\relax
> Hi
> \\bye
> # $source =~ s/\n/ /g; # workaround
> $pb = system("echo '$source' | pdftex --interaction=batchmode");
> warn "$pb\n";
> Uncommenting the workaround line make things work again.

You can't pipe complete documents into TeX when using batchmode; you
have to use scrollmode. It is also sensible to set the jobname, that
determines name of DVI and log file.

I.e., you'll use it as:

    my $latex_cmd = DC::Command->new("pdftex",
				     '-interaction', 'scrollmode',
				     '-jobname', $job_name, '\relax');

Where DC::Command->new is a wrapper to create an IO::Pipe.

I recently discovered that deficiency of TeX in a project of mine,
where I get ca. 600 MB data from a Web service, generate TeX source on
the fly, and pipe that into TeX for processing. Well, that the Log
file now has all the input, too, and needs to be sanitized later on --
if you ever need to keep processing log for reference, but except for
that, it works like a charm. (These 600MB are actually 12,000
documents, I later split the DVI file. This and several other
optimizations brought down processing time from 20 hours to 45


Joachim Schrod				Email: jschrod at acm.org
Roedermark, Germany

More information about the tex-k mailing list