Thread Perl mit Kommandozeilenprogramm kommunizieren (Windows) (79 answers)
Opened by bianca at 2013-09-10 13:07

bianca
 2013-09-14 01:12
#170212 #170212
User since
2009-09-13
6977 Artikel
BenutzerIn

user image
So ganz verstehe ich das nicht.
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/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";
            }
        }
    }
}

Quote
PID '3800'

Wieso liefert der Code keinen Fehler? Die Datei 'gpg2zum_test_falsch_geschrieben.exe' kann es garnicht finden, weil es sie nicht gibt?
10 print "Hallo"
20 goto 10

View full thread Perl mit Kommandozeilenprogramm kommunizieren (Windows)