From 232d78687663884df38c106f9089f637509722fd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Thu, 15 Oct 2015 13:59:55 +0200 Subject: [PATCH] =?utf8?q?R=C3=BCckgabewert=20von=20system-Aufrufen=20pr?= =?utf8?q?=C3=BCfen=20und=20ggf.=20Fehler=20ausgeben.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Template/HTML.pm | 8 ++++++-- SL/Template/LaTeX.pm | 19 +++++++++++++------ SL/Template/OpenDocument.pm | 14 +++++++++----- 3 files changed, 28 insertions(+), 13 deletions(-) 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(); -- 2.20.1