(note: OP silently changed the code after my post)
... >/null.txt
That would try to open a file in the root directory. Unless you have the appropriate privileges (i.e. run the command as root) this is likely to fail with "permission denied"... and the entire command won't execute. Maybe you meant >/dev/null?
Why aren't you checking if system(...) succeeded?
| [reply] [d/l] [select] |
My first guess is that the string you put togther for $cmd is not being interpreted right by pdftohtml, and is just quickly failing. It's not that it isn't waiting. Try something like this instead:
(experiment around till it works) :-)
#my $cmd = 'pdftohtml ' . $filename_pdf . ' ' . $filename_html . ' -no
+f
#+rames -c -i >/dev/null' ;
#system("$cmd");
my @args = ( $filename_pdf, $filename_html, 'noframes', '-c-, '-i' , '
+>', '/dev/null' );
system ('pdftohtml', @args);
Sometimes programs want '>', '/dev/null' , separated. Others might want '> /dev/null' as a single string. Try some variations in the @arg list until you get the desired output. I remember one tricky program I had, that wouldn't accept @args like '-o', "$filename", but needed "-o $filename".... took me all day to figure it out by trial and error. :-)
UPDATE It was pointed out to me that the /dev/null redirection, may be nonsense, in this particular instance. It didn't make much sense to me either, when I first saw it, but I have seen other apps, like mplayer or mencoder, which required the following odd redirection
$pid = open(MP, "| mplayer @options init.mpg >/dev/null 2>&1 ");
| [reply] [d/l] [select] |
I tried it your way, and I got "No such file" and "Permission denied". pdftohtml generates its output in the current working directory. I believe that if you try any other directory, it'll ignore the command and generate it in the current directory anyway. I tried it this way: #!/usr/bin/perl
use strict;
use warnings;
open(STDOUT, '>', 'htmllog');
my $cmd = 'pdftohtml -noframes -c /path/to/.pdf';
system($cmd);
exit;
Note that I wanted to keep a log to double check the number of pages. | [reply] [d/l] |
system PROGRAM LIST
Does exactly the same thing as exec LIST , except that a fork is done
+first,
This fork is why "the system call never waits for the conversion to happen"
Perldoc also provides a way to wait for return :
system(@args) == 0
or die "system @args failed: $?"
| [reply] [d/l] [select] |
| [reply] [d/l] |