0

I have some difficulties with my perl + gtk GUI app. Why can't perl catch bzip2's output text from console? Instead of being catched into variable, output is just printed in console. I have no problem with any other program - it's just bzip2.

My code:

wypisz($cmd);
my $out = `$cmd`;
wypisz($out);
wypisz("end");

Result: $cmd and "end" printed properly - nothing more. Bzip2's output is just printedwypisz() is my function used to put the text into gtkTextView:

sub wypisz {
    my $text = shift;
    my $textbuffer = $::Glade->get_widget( 'v_console' )->get_buffer;
    my $textiter = $textbuffer->get_end_iter;
    $textbuffer->insert($textiter,"$text\n");
    $::Glade->get_widget( 'v_console' )->set_buffer($textbuffer)
}
Rafał Swacha
  • 482
  • 2
  • 6
  • 20
  • check if bzip's writing to stderr. if it is, then you'd have to `$cmd 2>1` to redirect stderr to stdout. – Marc B Jan 16 '15 at 17:49

1 Answers1

3

Try

my $out = `$cmd 2>&1`;

to redirect stderr to stdout

FunkyShu
  • 138
  • 5