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

bianca
 2013-09-13 21:57
#170208 #170208
User since
2009-09-13
6977 Artikel
BenutzerIn

user image
OK, neuer Teilbaum :)
Windows Probleme gelöst.
Aber nun die entscheidende Frage: Wie kommuniziere ich denn nun mit dem Programm bidirektional?
Ich öffne gpg2.exe, erhalte von dem ein gpg: Go ahead and type your message ... zurück und will darauf jetzt antworten.
Wie mache ich das?
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
#!/usr/bin/perl
use strict;
use warnings;
use diagnostics;
use IPC::Cmd 0.84 qw[can_run run run_forked QUOTE];
# Achtung: Cmd.pm Zeile 235 muss auf Win 32Bit so lauten: my $abs = File::Spec->catfile( IS_WIN32 ? Win32::GetShortPathName( $dir ) : Win32::GetANSIPathName($dir), $command);
use Data::Dumper;

my %conf = (
    exe     => 'gpg2.exe',
);

my $full_path = can_run($conf{exe});
if (defined $full_path) {
    print "verwende Pfad '$full_path'\n";
    my $cmd = $full_path
        .''
    ;
    my @return = run(
        command => $cmd,
#       verbose => 0,
        buffer  =>\my $buffer,
        timeout => 20,
    );
#   print Dumper(\@return);
    if ($buffer =~ /gpg: Go ahead and type your message/i) {
        print WOHIN? "Test";
    }
#   if (defined $buffer) {
#       print "\n\nErgebnis:\n$buffer";
#   }
#   else {
#       print "Programmstart gescheitert\n";
#   }
}
else {
    print "Nicht installiert oder nicht im path\n";
}
10 print "Hallo"
20 goto 10

View full thread Perl mit Kommandozeilenprogramm kommunizieren (Windows)