1 2 3 4 5 6 7 8 9 10 11 12 13 14
#!/usr/bin/perl use 5.010; use strict; use warnings; $|=1; say "Bitte Eingaben: "; while (<>) { chomp; say "Konvertiere '$_' -> '\u$_'"; # Mach riesengroße Buchstaben am Anfang ;) } 1;
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
#!/usr/bin/perl use 5.010; use strict; use warnings; #$ENV{IPCRUNDEBUG}="data"; # debug modus use IPC::Run qw( start pump finish timeout harness ); my (@prog, $in, $out, $err); # Incrementally read from / write to scalars. # $in is drained as it is fed to cat's stdin, # $out accumulates cat's stdout # $err accumulates cat's stderr # $h is for "harness". @prog = ('perl','X:\bin\doit.pl' ); my $h = start \@prog, \$in, \$out, \$err, 10; # Erste Ausgabe des aufgerufenen Programms pump $h until length $out; # Prüfen ob Eingabe erwünscht if ($out =~ /Eingaben:/mg) { # und Eingabe an externes Programm raus $in = "aoeiooeiikmdujkdu\n"; $in .= "abcdefg\n"; $in .= "a\n"; $in .= "ax\n"; $in .= "asseae\n"; } # Hol Ausgabe des externes Programm ab pump $h until length $out; # und Schluss ... finish $h or die "@prog beendet mit Fehlercode $?"; # zeig was das Programm ausgegeben hat say "PROGRAMMAUSGABE:"; say $out;
1
2
3
4
Uncaught exception from user code:
process ended prematurely at test_ipc_run.pl line 23.
at C:/strawberry/perl/site/lib/IPC/Run.pm line 3262.
IPC::Run::pump('IPC::Run=HASH(0x131e164)') called at test_ipc_run.pl line 23
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
cpan> force install IPC::Run
Database was generated on Thu, 19 Sep 2013 07:29:11 GMT
Running install for module 'IPC::Run'
Running make for T/TO/TODDR/IPC-Run-0.92.tar.gz
Checksum for C:\strawberry\cpan\sources\authors\id\T\TO\TODDR\IPC-Run-0.92.tar.gz ok
Scanning cache C:\strawberry\cpan\build for sizes
......................................................................------DONE
DEL(1/2): C:\strawberry\cpan\build\Devel-NYTProf-5.03-_OQs32
DEL(2/2): C:\strawberry\cpan\build\Devel-NYTProf-5.03-_OQs32.yml
CPAN.pm: Going to build T/TO/TODDR/IPC-Run-0.92.tar.gz
Checking if your kit is complete...
Looks good
Writing Makefile for IPC::Run
Writing MYMETA.yml and MYMETA.json
cp lib/IPC/Run/Debug.pm blib\lib\IPC\Run\Debug.pm
cp lib/IPC/Run/Win32Pump.pm blib\lib\IPC\Run\Win32Pump.pm
cp lib/IPC/Run.pm blib\lib\IPC\Run.pm
cp lib/IPC/Run/Win32IO.pm blib\lib\IPC\Run\Win32IO.pm
cp lib/IPC/Run/IO.pm blib\lib\IPC\Run\IO.pm
cp lib/IPC/Run/Win32Helper.pm blib\lib\IPC\Run\Win32Helper.pm
cp lib/IPC/Run/Timer.pm blib\lib\IPC\Run\Timer.pm
TODDR/IPC-Run-0.92.tar.gz
C:\strawberry\c\bin\dmake.EXE -- OK
Running make test
C:\strawberry\perl\bin\perl.exe "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib\lib', 'blib\ar
ch')" t/*.t
t/97_meta.t .................. skipped: Author tests not required for installation
t/98_pod.t ................... skipped: Author tests not required for installation
t/98_pod_coverage.t .......... skipped: Author tests not required for installation
t/99_perl_minimum_version.t .. skipped: Author tests not required for installation
t/adopt.t .................... skipped: adopt not implemented yet
t/binmode.t .................. ok
t/bogus.t .................... ok
t/filter.t ................... ok
t/harness.t .................. ok
t/io.t ....................... ok
t/kill_kill.t ................ skipped: Temporarily ignoring test failure on Win32
t/parallel.t ................. skipped: Parallel tests are dangerous on MSWin32
t/pty.t ...................... skipped: IO::Pty not installed
t/pump.t ..................... ok
t/run.t ...................... ok
t/signal.t ................... skipped: Skipping on Win32
t/timeout.t .................. ok
t/timer.t .................... ok
t/win32_compile.t ............ ok
t/windows_search_path.t ...... Constant subroutine IPC::Run::Win32_MODE redefined at t/windows_searc
h_path.t line 11.
t/windows_search_path.t ...... ok
All tests successful.
Files=20, Tests=645, 50 wallclock secs ( 0.34 usr + 0.09 sys = 0.44 CPU)
Result: PASS
TODDR/IPC-Run-0.92.tar.gz
C:\strawberry\c\bin\dmake.EXE test -- OK
Running make install
Prepending C:\strawberry\cpan\build\IPC-Run-0.92-CO9KqJ/blib/arch C:\strawberry\cpan\build\IPC-Run-0
.92-CO9KqJ/blib/lib to PERL5LIB for 'install'
Appending installation info to C:\strawberry\perl\lib/perllocal.pod
TODDR/IPC-Run-0.92.tar.gz
C:\strawberry\c\bin\dmake.EXE install UNINST=1 -- OK
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";
1
2
3
4
5
6
7
8
9
10
11
12
13
14
IPC::Run 0001 [#1(3772)]: ****** harnessing *****
IPC::Run 0001 [#1(3772)]: parsing [ 'gpg2' ]
IPC::Run 0001 [#1(3772)]: parsing SCALAR
IPC::Run 0001 [#1(3772)]: parsing SCALAR
IPC::Run 0001 [#1(3772)]: parsing SCALAR
IPC::Run 0001 [#1(3772)]: parsing '10'
IPC::Run 0001 [#1(3772)]: ** starting
IPC::Run 0001 [#1(3772)]: _spawn_pumper pid = 4472
IPC::Run 0001 [#1(3772)]: _spawn_pumper pid = 4660
IPC::Run 0001 [#1(3772)]: _spawn_pumper pid = 4360
IPC::Run 0001 [#1(3772)]: spawning 'C:\Program Files\GNU\GnuPG\pub\gpg2.EXE'
IPC::Run 0001 [#1(3772)]: cmd line: "C:\Program Files\GNU\GnuPG\pub\gpg2.EXE"
IPC::Run 0001 [#1(3772)]: spawn() = 2260
IPC::Run 0001 [#1(3772)]: ** pumping
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#!/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); $|=1; my @prog = qw (gpg.exe -v -e); # verschlüsseln my $handle = start \@prog, \$in, \$out, \$err, 10; pump $handle until length $err; if ($err =~ /gpg:/mg) { $in = "Kleiner Test\r\n"; } pump $handle until length $err; finish $handle or die "@prog beendet mit Fehlercode $?"; print "Ausgabe:\n$out";
Quote(...)
$CHILD_ERROR
$?
The status returned by the last pipe close, backtick (`` ) command, successful call to wait() or waitpid(), or from the system() operator. This is just the 16-bit status word returned by the traditional Unix wait() system call (or else is made up to look like it). Thus, the exit value of the subprocess is really ($?>> 8 ), and $? & 127 gives which signal, if any, the process died from, and $? & 128 reports whether there was a core dump.
$real_errorcode = $?>>8;