http://www.perlmonks.org?node_id=981048


in reply to Re^2: Redirect output of the system() command
in thread Redirect output of the system() command

A bit modified version (as soon as I need to quote some options too):
my @options = qw( --orientation Portrait --page-size A4 --title "Rechnung" --footer-right "created by Manager www.somesite.ch" ); $config->{wkhtmltopdf_path} =~ s{ }{\\ }g; $source_file =~ s{ }{\\ }g; $config->{result_filename} =~ s{ }{\\ }g; my $command = "(" . join(" ", $config->{wkhtmltopdf_path}, @options, $ +source_file, $config->{result_filename}) . ")"; $command =~ s/\"/\\\"/g; system( "/bin/bash -c \"$command\" >/dev/null 2>&1" );