Thread Perl mit Kommandozeilenprogramm kommunizieren (Windows)
(79 answers)
Opened by bianca at 2013-09-10 13:07
Habe das mal mit unserem berühmten pgp2 probiert:
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 #!/usr/bin/perl use strict; use warnings; use diagnostics; use Data::Dumper; use IPC::Run qw(start pump finish timeout harness); $ENV{IPCRUNDEBUG}="data"; # debug modus my ($in,$out,$err); my @prog = ('gpg2'); my $handle = start \@prog, \$in, \$out, \$err, 10; pump $handle until length $out; if ($out =~ /gpg: Go ahead and type your message/mg) { $in = "Kleiner Test\r\n"; } pump $handle until length $out; finish $handle or die "@prog beendet mit Fehlercode $?"; print "Ausgabe:\n$out"; Dump Ausgabe: Code: (dl
)
1 IPC::Run 0001 [#1(3772)]: ****** harnessing ***** Und kehrt leider nicht zurück, muss ich mit STRG C abbrechen. Hast du eine Idee, warum das so ist? 10 print "Hallo"
20 goto 10 |