From e203e5fd849788fae923c3a9e5d9a03c6f29affc Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 20 Jan 2012 23:41:02 +0000 Subject: output of pv script only if any returned diff --git a/rhimport.pm b/rhimport.pm index fbecbc1..0d7fee8 100644 --- a/rhimport.pm +++ b/rhimport.pm @@ -330,7 +330,7 @@ sub delete_file sub pv_add_note { my ( $title, $text, $id, $date, $type ) = @_; - $type = 'n' unless $type; + $type = 'n' if undef($type); # TODO: implement type as soon pv supports this my @script = ('/usr/bin/ssh', 'root@intranet', 'addnote', $id, $date); @@ -345,14 +345,16 @@ sub pv_add_note print $writer $title . "\n" . $text; close $writer; waitpid $pid, 0; + $err_out = join('', <$error>); + $read_out = join('', <$reader>); if ( $? >> 8 ) { print "\n\nPV: adding note returned non-zero value\n"; - print "STDERR:\n" . join('', <$error>) . "\n"; - print "STDOUT:\n" . join('', <$reader>) . "\n"; + print "STDERR:\n" . $err_out . "\n" unless $err_out eq ''; + print "STDOUT:\n" . $read_out . "\n" unless $read_out eq ''; print "Ignoring failed headline import!\n"; } else { - print join('', <$reader>) . "\n"; - print join('', <$error>) . "\n"; + print $read_out . "\n" unless $read_out eq ''; + print $err_out . "\n" unless $err_out eq ''; } } -- cgit v0.10.2