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
#!/usr/bin/perl use strict; use warnings; use diagnostics; use IPC::Cmd qw[can_run run run_forked QUOTE]; 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 .'' ; run( command => $cmd, # verbose => 0, buffer =>\my $buffer, timeout => 20, ); if (defined $buffer) { print "\n\nErgebnis:\n".Dumper(\$buffer); } else { print "Programmstart gescheitert\n"; } } else { print "Nicht installiert oder nicht im path\n"; }
Quoteverwende Pfad 'C:\Program Files\GNU\GnuPG\pub\gpg2.exe'
Programmstart gescheitert
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
#!/usr/bin/perl use strict; use warnings; use diagnostics; use IPC::Cmd qw[can_run run run_forked QUOTE]; 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 (defined $buffer) { print "\n\nErgebnis:\n".Dumper(\$buffer); } else { print "Programmstart gescheitert\n"; } } else { print "Nicht installiert oder nicht im path\n"; }
1
2
3
4
5
6
7
8
9
10
verwende Pfad 'C:\Program Files\GNU\GnuPG\pub\gpg2.exe'
$VAR1 = [
undef,
'file not found: C:\\Program at C:/strawberry/perl/lib/IPC/Cmd.pm line 1166.
',
[],
[],
[]
];
Programmstart gescheitert
my $abs = File::Spec->catfile( IS_WIN32 ? Win32::GetShortPathName( $dir ) : $dir, $command);
my $abs = File::Spec->catfile( IS_WIN32 ? Win32::GetShortPathName( $dir ) : Win32::GetANSIPathName($dir), $command);