From: Bernd Bleßmann Date: Thu, 15 Oct 2015 11:59:55 +0000 (+0200) Subject: Rückgabewert von system-Aufrufen prüfen und ggf. Fehler ausgeben. X-Git-Tag: release-3.4.1~636 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=232d78687663884df38c106f9089f637509722fd;p=kivitendo-erp.git Rückgabewert von system-Aufrufen prüfen und ggf. Fehler ausgeben. --- diff --git a/SL/Template/HTML.pm b/SL/Template/HTML.pm index 09f24fceb..ecc3410a8 100644 --- a/SL/Template/HTML.pm +++ b/SL/Template/HTML.pm @@ -70,7 +70,9 @@ sub convert_to_postscript { $psfile .= ".ps"; } - system($::lx_office_conf{applications}->{html2ps} . " -f html2ps-config < $form->{tmpfile} > $psfile"); + if (system($::lx_office_conf{applications}->{html2ps} . " -f html2ps-config < $form->{tmpfile} > $psfile") == -1) { + die "system call to $::lx_office_conf{applications}->{html2ps} failed: $!"; + } if ($?) { $self->{"error"} = $form->cleanup($::lx_office_conf{applications}->{html2ps}); return 0; @@ -102,7 +104,9 @@ sub convert_to_pdf { $pdffile .= ".pdf"; } - system($::lx_office_conf{applications}->{html2ps} . " -f html2ps-config < $form->{tmpfile} | ps2pdf - $pdffile"); + if (system($::lx_office_conf{applications}->{html2ps} . " -f html2ps-config < $form->{tmpfile} | ps2pdf - $pdffile") == -1) { + die "system call to $::lx_office_conf{applications}->{html2ps} failed: $!"; + } if ($?) { $self->{"error"} = $form->cleanup($::lx_office_conf{applications}->{html2ps}); return 0; diff --git a/SL/Template/LaTeX.pm b/SL/Template/LaTeX.pm index 6ec4d96a3..352f793e1 100644 --- a/SL/Template/LaTeX.pm +++ b/SL/Template/LaTeX.pm @@ -482,8 +482,10 @@ sub convert_to_postscript { $ENV{openin_any} = "p"; for (my $run = 1; $run <= 2; $run++) { - system("${latex} --interaction=nonstopmode $form->{tmpfile} " . - "> $form->{tmpfile}.err"); + if (system("${latex} --interaction=nonstopmode $form->{tmpfile} " . + "> $form->{tmpfile}.err") == -1) { + die "system call to $latex failed: $!"; + } if ($?) { $ENV{HOME} = $old_home; $ENV{openin_any} = $old_openin_any; @@ -494,12 +496,14 @@ sub convert_to_postscript { $form->{tmpfile} =~ s/tex$/dvi/; - system("dvips $form->{tmpfile} -o -q > /dev/null"); + if (system("dvips $form->{tmpfile} -o -q > /dev/null") == -1) { + die "system call to dvips failed: $!"; + } $ENV{HOME} = $old_home; $ENV{openin_any} = $old_openin_any; if ($?) { - $self->{"error"} = "dvips : $!"; + $self->{"error"} = "dvips : $?"; $self->cleanup('dvips'); return 0; } @@ -532,8 +536,11 @@ sub convert_to_pdf { $ENV{openin_any} = "p"; for (my $run = 1; $run <= 2; $run++) { - system("${latex} --interaction=nonstopmode $form->{tmpfile} " . - "> $form->{tmpfile}.err"); + if (system("${latex} --interaction=nonstopmode $form->{tmpfile} " . + "> $form->{tmpfile}.err") == -1) { + die "system call to $latex failed: $!"; + } + if ($?) { $ENV{HOME} = $old_home; $ENV{openin_any} = $old_openin_any; diff --git a/SL/Template/OpenDocument.pm b/SL/Template/OpenDocument.pm index 704d5e7e0..50c191bc3 100644 --- a/SL/Template/OpenDocument.pm +++ b/SL/Template/OpenDocument.pm @@ -510,7 +510,9 @@ sub spawn_xvfb { $main::lxdebug->message(LXDebug->DEBUG2(), " xauthority $xauthority\n"); - system("xauth add \"${display}\" . \"${mcookie}\""); + if (system("xauth add \"${display}\" . \"${mcookie}\"") == -1) { + die "system call to xauth failed: $!"; + } if ($? != 0) { $self->{"error"} = "Conversion to PDF failed because OpenOffice could not be started (xauth: $!)"; $main::lxdebug->leave_sub(); @@ -673,10 +675,12 @@ sub convert_to_pdf { } if (!$::lx_office_conf{print_templates}->{openofficeorg_daemon}) { - system($::lx_office_conf{applications}->{openofficeorg_writer}, - "-minimized", "-norestore", "-nologo", "-nolockcheck", "-headless", - "file:${filename}.odt", - "macro://" . (split('/', $filename))[-1] . "/Standard.Conversion.ConvertSelfToPDF()"); + if (system($::lx_office_conf{applications}->{openofficeorg_writer}, + "-minimized", "-norestore", "-nologo", "-nolockcheck", "-headless", + "file:${filename}.odt", + "macro://" . (split('/', $filename))[-1] . "/Standard.Conversion.ConvertSelfToPDF()") == -1) { + die "system call to $::lx_office_conf{applications}->{openofficeorg_writer} failed: $!"; + } } else { if (!$self->spawn_openoffice()) { $main::lxdebug->leave_sub();