1 2 3 4 5 6 7 8
sub execute_cmd { my $cmd = shift; print "Details: $cmd\n"; if ( system( $cmd ) == 0 or die "Error: $?" ) { return( `$cmd` ); } }
1 2 3 4 5 6 7 8
sub execute_cmd { my $cmd = shift; print "Details: $cmd\n"; my @ret = `$cmd`; warn "#### Error: $cmd cannot be executed!" if not @ret; return @ret; }
1 2 3 4 5 6 7 8 9 10
sub execute_cmd { my $cmd = shift; my $cmd_return; print "Details: $cmd\n"; $cmd_return = `$cmd`; if ( $? == 0 or die "Error: $?" ) { return $cmd_return; } }
1 2 3 4 5 6
if ( $? == 0 ) { return $cmd_return; } else { die "$cmd failed with error: $?"; }
open my $x, "< file" or die;
1 2 3 4 5 6 7 8 9 10 11
#!/usr/bin/perl use strict; use warnings; my $y = 1; my $x = ($y or die "leer"); print "$x\n"; $y = 0; $x = ($y or die "leer"); print "$x\n";
$cmd_return = `$cmd 1>&2`;
2011-12-15T11:52:12 sureshDer Output ist wieder vollständig, wenn ich STDOUT nach STDERR umleite:
Code (perl): (dl )$cmd_return = `$cmd 1>&2`;
Quotedu musst den inhalt von $cmd_return natürlich mittels print auch ausgeben.