Discussion:
A problem running LaTeX from a daemon
Marc Balmer
2014-08-10 15:45:49 UTC
Permalink
I have a daemon that provides a webservice (using FastCGI behind a lighttpd server) on NetBSD 5.0. It produces PDF documents by creating a .tex file, then running LaTeX, dvips, and ps2pdf on it.

The exact sequence of command is:

latex <filename> >/dev/null
latex <filename> >/dev/null
dvips -Ppdf -G0 <filename>.dvi >/dev/null 2>&1
ps2pdf <filename>.ps >/dev/null

The daemon is started with a script in /etc/rc.d.

Now my problem is, when this sequence of commands is run from the daemon which was started a system boot time, it does not work. It creates a PDF (so ps2pdf does run), but it is empty. So 'latex' did not run or did not produce any dvi file.

If I, however, log in to the machine as root and restart the daemon (/etc/rc.d/<name> restart), it works as expected, creates and delivers the PDF.

Right now, I am a bit clueless as which could cause this. Lack of a controlling tty when started during boot?

Any hints would be appreciated...

- Marc
Greg Troxel
2014-08-10 16:12:23 UTC
Permalink
Post by Marc Balmer
latex <filename> >/dev/null
latex <filename> >/dev/null
dvips -Ppdf -G0 <filename>.dvi >/dev/null 2>&1
ps2pdf <filename>.ps >/dev/null
The daemon is started with a script in /etc/rc.d.
Now my problem is, when this sequence of commands is run from the
daemon which was started a system boot time, it does not work. It
creates a PDF (so ps2pdf does run), but it is empty. So 'latex' did
not run or did not produce any dvi file.
If I, however, log in to the machine as root and restart the daemon (/etc/rc.d/<name> restart), it works as expected, creates and delivers the PDF.
Right now, I am a bit clueless as which could cause this. Lack of a controlling tty when started during boot?
I would definitely suggest either the lack of controlling tty or stdin.
latex is not interactive if the input is ok, but if it hits problems
then (tex really) will prompt.

So it would not surprise me if stdin were checked early on just in case
and there is trouble if latex/tex is not satisfied.

So I would try an explicit redirect to /dev/null; I'm not at all clear
on stdin at rc.conf time.

You could also run the command under ktrace and see what it does to stdin.
Martin Husemann
2014-08-10 16:48:11 UTC
Permalink
Post by Marc Balmer
Right now, I am a bit clueless as which could cause this. Lack of a controlling tty when started during boot?
My bet would be on subtle differences in the environment.

Martin
John Hawkinson
2014-08-10 18:38:27 UTC
Permalink
Post by Marc Balmer
latex <filename> >/dev/null
dvips -Ppdf -G0 <filename>.dvi >/dev/null 2>&1
Step one should be to stop redirecting stdout (and stderr!) to /dev/null
and instead send them to a file and read it.

--jhawk
i***@netbsd.org
2014-08-11 07:47:29 UTC
Permalink
Post by Marc Balmer
I have a daemon that provides a webservice (using FastCGI behind a lighttpd server) on NetBSD 5.0. It produces PDF documents by creating a .tex file, then running LaTeX, dvips, and ps2pdf on it.
latex <filename> >/dev/null
latex <filename> >/dev/null
dvips -Ppdf -G0 <filename>.dvi >/dev/null 2>&1
ps2pdf <filename>.ps >/dev/null
The daemon is started with a script in /etc/rc.d.
Now my problem is, when this sequence of commands is run from
the daemon which was started a system boot time, it does not work.
It creates a PDF (so ps2pdf does run), but it is empty. So 'latex'
did not run or did not produce any dvi file.
Hm. You say ps2pdf runs, so the script (or well, the daemon) has a
writable current working directory? In this case, what does the
<filename>.log say?

(I've had such an effect with a script that ran before /var or /usr
was mounted.. but I think this can be ruled out?)

Regards,
-is
Aleksej Saushev
2014-09-01 18:10:56 UTC
Permalink
Post by Marc Balmer
I have a daemon that provides a webservice (using FastCGI behind
a lighttpd server) on NetBSD 5.0. It produces PDF documents by
creating a .tex file, then running LaTeX, dvips, and ps2pdf on
it.
latex <filename> >/dev/null
latex <filename> >/dev/null
I'd suggest "latex -interaction nonstopmode <filename>"
or "-interaction batchmode" for non-interactive use.
(Also, you may need to run it one more time.)
--
HE CE3OH...
Loading...