#!/usr/bin/perl use strict; use warnings; use diagnostics; use Data::Dumper; use IPC::Open3; use IO::Select; my %conf = ( pfad => 'C:/Program Files/GNU/GnuPG/pub', exe => 'gpg2zum_test_falsch_geschrieben.exe', ); my ($pid,$infh,$outfh,$errfh); eval { $pid = open3($infh,$outfh,$errfh,"$conf{pfad}/$conf{exe}"); }; if ($@) { print "Fehler '$@' beim Programmstart\n"; } else { print "PID '$pid'\n"; my $sel = new IO::Select; $sel->add($outfh,$errfh); local *OUTPUT; local *ERRLOG; while(my @ready = $sel->can_read) { foreach my $fh (@ready) { my $line = <$fh>; if(not defined $line){ $sel->remove($fh); next; } if($fh == $outfh) { print OUTPUT $line; } elsif($fh == $errfh) { print ERRLOG $line; } else { die "Shouldn't be here\n"; } } } }