[l2h] Cannot convert images in test sample file

Ross Moore ross@ics.mq.edu.au
Thu, 29 Nov 2001 12:14:33 +1100 (EST)

Hi Darrell,

Thanks for tackling this issue.

> > According to this, it may be that the NT operating system, or a process
> > initiated by browser software, is deleting the contents of the temporary
> > directory *before* LaTeX2HTML has finished using those files.
> I realize that some are not as fortunate as others and must run NT :-) but
> it is not Nt that is deleting them.  It is, as you say, lth that is deleting
> them.  The problem is, at least by my observations, that l2h for some reason
> (when trying to convert the images) sometimes wants to use the same
> directory it used in the previous run, which is of course, no longer exists
> because l2h "deleted" it :-)

I find that hard to believe (given the coding below) .....

  ... but you have the experience of it, so maybe it's true.

If you can track the cause, then of course I'd be happy to "fix" the
Perl coding, or include a work-around of some OS bug, if that's what it is.

Here is what LaTeX2HTML uses:

    # determine a suitable temporary path
    $TMPDIR = '';
    my @tmp_try = ();
    push(@tmp_try, $TMP) if($TMP);
    push(@tmp_try, "$DESTDIR$dd$TMP_") if($TMP_);
    push(@tmp_try, $DESTDIR) if($DESTDIR);
    push(@tmp_try, L2hos->Cwd());

    my $try;
    TempTry: foreach $try (@tmp_try) {
      next unless(-d $try && -w _);
      my $tmp = "$try$dd$TMP_PREFIX$$";
      if(mkdir($tmp,0755)) {
        last TempTry;
      } else {
        warn "Warning: Cannot create temporary directory '$tmp': $!\n";

It's not my coding, but it looks OK to me.
First we build a list of possible places for a temporary directory,
pushing these into a list  @tmp_try .
Then check these for the directory both existing and being writable.
When a suitable place has been found, create a subdirectory
 e.g.  <dir-path>/l2h<num>

$try ---> <dir-path>
$dd  ---> /
$TMP_PREFIX  --->  l2h
$$ ---------> <num>

The values of these variables may change according to platform
and/or user customisations.

If the  mkdir  fails then there should be a warning message.

If no directory is writable, then I suppose we can fall out of 
the loop, leaving  $TMPDIR  empty.
But this shouldn't happen, as one of the options is the location
where the HTML files will be created; so if that isn't writable
then the whole job will fail anyway.
Furthermore, this isn't what you said was happening.

The <num> comes from  $$  so should be *unique* to the running job.
(If not, then maybe there's a problem with the Perl installation.)

> This is NT, and I doubt that NT is the culprit.  L2h is looking for
> something that simply is not there (but was there on a previous run.)  I'm
> not saying it's l2h's fault either.  hel, it's probably the operator's
> fault!  ...but highly improbable :-).  I _thought) I was wrong once, but it
> turned out I was mistaken about that :-)

I suppose that it's possible that the  LaTeX2HTML job is somehow executing
its  &cleanup  subroutine *before* the image-generation processes have

You could easily test this by adding some  print  lines into
the subroutine block, which starts:

  sub cleanup {
    local($explicit) = @_;
    return unless $explicit || !$DEBUG;

Find where it removes  $TMPDIR  :

    if ($TMPDIR && opendir(DIR, $TMPDIR)) {
        local(@files) = grep(!/^\.\.?$/,readdir(DIR));
        foreach (@files) {
            $busy .= $_." " unless (L2hos->Unlink("$TMPDIR$dd$_"));
        closedir (DIR);
        if ($busy) {
            print "\n\nFiles: $busy  are still in use.\n\n" if ($DEBUG);
        } else {
            &write_warnings("\n\n Couldn't remove $TMPDIR : $!")
                unless (rmdir $TMPDIR);

Note that there are already warning messages about files still in use.
However, if this code is called (for reasons as yet unknown) *before*
 pstoimg  tries to use them, then those messages will not be generated.

The  &cleanup  subroutine is meant to be called at the beginning of a job,
so as to remove any old files that may be in the temporary directories;
then also at the end of the job, to remove stuff that should never
be needed again.

> Thank you for your assistance.

Try sticking in some suitable messages, giving the values of $$
and $TMPDIR,  then just use LaTeX2HTML as usual.
If the problem occurs again, then you may get something meaningful.

Hope this helps,

	Ross Moore

> Darrell
> >
> >
> > Thanks for the observations.
> >
> > I hope you can figure what is causing the problem and find
> > a simple fix for it.
> >
> >
> > All the best,
> >
> > Ross Moore
> >
> >
> > > Darrell
> > > _______________________________________________
> > > latex2html mailing list
> > > latex2html@tug.org
> > > http://tug.org/mailman/listinfo/latex2html
> >
> > _______________________________________________
> > latex2html mailing list
> > latex2html@tug.org
> > http://tug.org/mailman/listinfo/latex2html
> >
> _______________________________________________
> latex2html mailing list
> latex2html@tug.org
> http://tug.org/mailman/listinfo/latex2html